EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.view]

COVERAGE SUMMARY FOR SOURCE FILE [ParticipantListModel.java]

nameclass, %method, %block, %line, %
ParticipantListModel.java100% (6/6)100% (19/19)100% (325/325)100% (52/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ParticipantListModel100% (1/1)100% (9/9)100% (244/244)100% (33/33)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
ParticipantListModel (Board, AccountRepository, Channel): void 100% (1/1)100% (158/158)100% (21/21)
access$000 (ParticipantListModel): void 100% (1/1)100% (3/3)100% (1/1)
access$100 (ParticipantListModel, int): Participant 100% (1/1)100% (4/4)100% (1/1)
access$200 (ParticipantListModel, int): int 100% (1/1)100% (4/4)100% (1/1)
access$300 (ParticipantListModel, int): int 100% (1/1)100% (4/4)100% (1/1)
access$400 (ParticipantListModel, int, int): void 100% (1/1)100% (5/5)100% (1/1)
access$500 (ParticipantListModel, int, boolean): void 100% (1/1)100% (5/5)100% (1/1)
refresh (): void 100% (1/1)100% (57/57)100% (10/10)
     
class ParticipantListModel$1100% (1/1)100% (2/2)100% (10/10)100% (3/3)
ParticipantListModel$1 (ParticipantListModel): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (4/4)100% (2/2)
     
class ParticipantListModel$2100% (1/1)100% (2/2)100% (15/15)100% (3/3)
ParticipantListModel$2 (ParticipantListModel): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (9/9)100% (2/2)
     
class ParticipantListModel$3100% (1/1)100% (2/2)100% (15/15)100% (3/3)
ParticipantListModel$3 (ParticipantListModel): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (9/9)100% (2/2)
     
class ParticipantListModel$4100% (1/1)100% (2/2)100% (28/28)100% (7/7)
ParticipantListModel$4 (ParticipantListModel): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (22/22)100% (6/6)
     
class ParticipantListModel$5100% (1/1)100% (2/2)100% (13/13)100% (3/3)
ParticipantListModel$5 (ParticipantListModel): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (7/7)100% (2/2)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveboard.view;
16 
17import java.util.ArrayList;
18import java.util.List;
19 
20import org.apache.commons.logging.Log;
21import org.apache.commons.logging.LogFactory;
22 
23import net.sourceforge.hiveboard.Board;
24import net.sourceforge.hiveboard.Event;
25import net.sourceforge.hiveboard.EventType;
26import net.sourceforge.hiveboard.event.Constraints;
27import net.sourceforge.hiveboard.event.DeferredConsumer;
28import net.sourceforge.hiveboard.model.AccountRepository;
29import net.sourceforge.hiveboard.util.AbstractParticipantListModel;
30import net.sourceforge.hiveboard.util.Participant;
31import net.sourceforge.hiveevents.Channel;
32 
33public class ParticipantListModel extends AbstractParticipantListModel
34{
35        static private final Log        _logger = LogFactory.getLog(ParticipantListModel.class);
36        
37        public ParticipantListModel(Board                                board,
38                                                                AccountRepository        repository,
39                                                                Channel<Event>                eventChannel)
40        {
41                super(board, repository);
42                if (_logger.isDebugEnabled())
43                {
44                        _logger.debug("<init> board=" + board.getId() + ", writer=" + board.getWriter());
45                }
46 
47                refresh();
48                installConsumers(eventChannel);
49                
50                // Add events listeners
51                // participants list
52                _consumerModifyBoard = new DeferredConsumer()
53                {
54                        @Override protected void pushEvent(Event event)
55                        {
56                                // Just a refresh is needed, since _board has been updated from
57                                // BoardRepository!
58                                refresh();
59                        }
60                };
61                String constraint;
62                constraint = Constraints.eventTypeWhere(_board.getId(), EventType.EVT_MODIFY_BOARD);
63                registerConsumer(eventChannel, constraint, _consumerModifyBoard);
64 
65                _consumerAddParticipant = new DeferredConsumer()
66                {
67                        @Override protected void pushEvent(Event event)
68                        {
69                                addRow(createParticipant(event.getWho()));
70                        }
71                };
72                constraint = Constraints.eventTypeWhere(
73                                                                        _board.getId(), EventType.EVT_BOARD_ADD_PARTICIPANT);
74                registerConsumer(eventChannel, constraint, _consumerAddParticipant);
75 
76                _consumerDelParticipant = new DeferredConsumer()
77                {
78                        @Override protected void pushEvent(Event event)
79                        {
80                                removeRow(findParticipant(event.getWho()));
81                        }
82                };
83                constraint =        Constraints.eventTypeWhere(
84                                                                        _board.getId(), EventType.EVT_BOARD_DEL_PARTICIPANT) +
85                                                " || " + Constraints.eventType(EventType.EVT_DESTROY_ACCOUNT);
86                registerConsumer(eventChannel, constraint, _consumerDelParticipant);
87 
88                // token request
89                _consumerRequest = new DeferredConsumer()
90                {
91                        @Override protected void pushEvent(Event event)
92                        {
93                                int index = findParticipant(event.getWho());
94                                if (index >= 0)
95                                {
96                                        Participant person = getRow(index);
97                                        person.setRequester();
98                                        fireRowsModified(index, index);
99                                }
100                        }
101                };
102                constraint = Constraints.eventTypeWhere(_board.getId(), EventType.EVT_REQUEST_TOKEN);
103                registerConsumer(eventChannel, constraint, _consumerRequest);
104 
105                // present persons
106                _consumerJoinLeave = new DeferredConsumer()
107                {
108                        @Override protected void pushEvent(Event event)
109                        {
110                                updateParticipant(event.getWho(), false);
111                        }
112                };
113                constraint = Constraints.eventTypeWhere(
114                                                _board.getId(), EventType.EVT_JOIN_BOARD, EventType.EVT_LEAVE_BOARD);
115                registerConsumer(eventChannel, constraint, _consumerJoinLeave);
116        }
117        
118        private void refresh()
119        {
120                _logger.debug("refresh() board=" + _board.getId());
121                _writer = _board.getWriter();
122                List<Participant> participants = 
123                                                        new ArrayList<Participant>(_board.getParticipants().size());
124                for (int id: _board.getParticipants())
125                {
126                        Participant participant = createParticipant(id);
127                        if (participant != null)
128                        {
129                                participants.add(participant);
130                        }
131                }
132 
133                setRows(participants.toArray(new Participant[participants.size()]));
134        }
135        
136        private final DeferredConsumer        _consumerModifyBoard;
137        private final DeferredConsumer        _consumerAddParticipant;
138        private final DeferredConsumer        _consumerDelParticipant;
139        private final DeferredConsumer        _consumerRequest;
140        private final DeferredConsumer        _consumerJoinLeave;
141}

[all classes][net.sourceforge.hiveboard.view]
EMMA 2.0.5312 (C) Vladimir Roubtsov