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

COVERAGE SUMMARY FOR SOURCE FILE [GuiContext.java]

nameclass, %method, %block, %line, %
GuiContext.java100% (10/10)98%  (43/44)97%  (387/399)96%  (81.9/85)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GuiContext$9100% (1/1)100% (1/1)88%  (29/33)87%  (0.9/1)
<static initializer> 100% (1/1)88%  (29/33)87%  (0.9/1)
     
class GuiContext100% (1/1)96%  (26/27)96%  (211/219)94%  (47/50)
removeContextListener (GuiContextListener): void 0%   (0/1)0%   (0/6)0%   (0/2)
setIdentityHolder (IdentityHolder): void 100% (1/1)80%  (8/10)75%  (3/4)
GuiContext (): void 100% (1/1)100% (29/29)100% (9/9)
access$002 (GuiContext, Participant): Participant 100% (1/1)100% (5/5)100% (1/1)
access$102 (GuiContext, Event): Event 100% (1/1)100% (5/5)100% (1/1)
access$200 (GuiContext): Board 100% (1/1)100% (3/3)100% (1/1)
access$202 (GuiContext, Board): Board 100% (1/1)100% (5/5)100% (1/1)
access$300 (GuiContext): BoardImageModel 100% (1/1)100% (3/3)100% (1/1)
access$302 (GuiContext, BoardImageModel): BoardImageModel 100% (1/1)100% (5/5)100% (1/1)
access$402 (GuiContext, Board): Board 100% (1/1)100% (5/5)100% (1/1)
access$502 (GuiContext, Account): Account 100% (1/1)100% (5/5)100% (1/1)
addContextListener (GuiContextListener): void 100% (1/1)100% (9/9)100% (3/3)
getAccount (): Account 100% (1/1)100% (3/3)100% (1/1)
getBoard (): Board 100% (1/1)100% (3/3)100% (1/1)
getDrawBoard (): Board 100% (1/1)100% (3/3)100% (1/1)
getIdentity (): Account 100% (1/1)100% (4/4)100% (1/1)
getImageModel (): BoardImageModel 100% (1/1)100% (3/3)100% (1/1)
getNotification (): Event 100% (1/1)100% (3/3)100% (1/1)
getParticipant (): Participant 100% (1/1)100% (3/3)100% (1/1)
setAccountChannel (Channel): void 100% (1/1)100% (11/11)100% (3/3)
setBoardChannel (Channel): void 100% (1/1)100% (11/11)100% (3/3)
setBoardImageChannel (Channel): void 100% (1/1)100% (11/11)100% (3/3)
setEventChannel (Channel): void 100% (1/1)100% (17/17)100% (4/4)
setIdentityChannel (Channel): void 100% (1/1)100% (11/11)100% (3/3)
setNotificationChannel (Channel): void 100% (1/1)100% (11/11)100% (3/3)
setParticipantChannel (Channel): void 100% (1/1)100% (11/11)100% (3/3)
update (): void 100% (1/1)100% (24/24)100% (3/3)
     
class GuiContext$1100% (1/1)100% (2/2)100% (10/10)100% (3/3)
GuiContext$1 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
push (Account): void 100% (1/1)100% (4/4)100% (2/2)
     
class GuiContext$2100% (1/1)100% (2/2)100% (15/15)100% (4/4)
GuiContext$2 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
push (Participant): void 100% (1/1)100% (9/9)100% (3/3)
     
class GuiContext$3100% (1/1)100% (2/2)100% (15/15)100% (4/4)
GuiContext$3 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
push (Event): void 100% (1/1)100% (9/9)100% (3/3)
     
class GuiContext$4100% (1/1)100% (2/2)100% (15/15)100% (4/4)
GuiContext$4 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
push (Board): void 100% (1/1)100% (9/9)100% (3/3)
     
class GuiContext$5100% (1/1)100% (2/2)100% (38/38)100% (9/9)
GuiContext$5 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
push (DrawingAreaHolder): void 100% (1/1)100% (32/32)100% (8/8)
     
class GuiContext$6100% (1/1)100% (2/2)100% (15/15)100% (4/4)
GuiContext$6 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
push (Account): void 100% (1/1)100% (9/9)100% (3/3)
     
class GuiContext$7100% (1/1)100% (2/2)100% (29/29)100% (4/4)
GuiContext$7 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
passEvent (Event): boolean 100% (1/1)100% (23/23)100% (3/3)
     
class GuiContext$8100% (1/1)100% (2/2)100% (10/10)100% (3/3)
GuiContext$8 (GuiContext): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (4/4)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.util;
16 
17import javax.swing.event.EventListenerList;
18 
19import net.sourceforge.hiveboard.Account;
20import net.sourceforge.hiveboard.Board;
21import net.sourceforge.hiveboard.Event;
22import net.sourceforge.hiveboard.event.EventsPriorities;
23import net.sourceforge.hiveboard.event.PersistentDeferredConsumer;
24import net.sourceforge.hiveboard.main.IdentityHolder;
25import net.sourceforge.hiveboard.model.BoardImageModel;
26import net.sourceforge.hiveboard.view.DrawingAreaHolder;
27import net.sourceforge.hiveevents.Channel;
28import net.sourceforge.hiveevents.Filter;
29import net.sourceforge.hiveevents.PersistentConsumer;
30 
31/**
32 * @author Jean-Francois Poilpret
33 */
34final public class GuiContext
35{
36        public void        addContextListener(GuiContextListener l)
37        {
38                _listeners.add(GuiContextListener.class, l);
39                // Force update
40                l.contextChanged(this);
41        }
42        
43        public void        removeContextListener(GuiContextListener l)
44        {
45                _listeners.remove(GuiContextListener.class, l);
46        }
47        
48        public void        setIdentityHolder(IdentityHolder identity)
49        {
50                _identity = identity;
51                if (_identity.getIdentity() != null)
52                {
53                        update();
54                }
55        }
56 
57        public void        setIdentityChannel(Channel<Account> identityChannel)
58        {
59                int priority = EventsPriorities.GUI_STATE_UPDATE;
60                identityChannel.registerPushConsumer(priority, new PersistentConsumer<Account>()
61                 {
62                         public void        push(Account event)
63                         {
64                                 update();
65                         }
66                 });
67        }
68 
69        public void        setParticipantChannel(Channel<Participant> participantChannel)
70        {
71                int priority = EventsPriorities.GUI_STATE_UPDATE;
72                participantChannel.registerPushConsumer(priority, new PersistentConsumer<Participant>()
73                {
74                        public void        push(Participant participant)
75                        {
76                                _participant = participant;
77                                update();
78                        }
79                });
80        }
81        
82        public void        setNotificationChannel(Channel<Event> notificationChannel)
83        {
84                int priority = EventsPriorities.GUI_STATE_UPDATE;
85                notificationChannel.registerPushConsumer(priority, new PersistentConsumer<Event>()
86                 {
87                         public void        push(Event e)
88                         {
89                                 _notification = e;
90                                 update();
91                         }
92                 });
93        }
94 
95        public void        setBoardChannel(Channel<Board> boardChannel)
96        {
97                int priority = EventsPriorities.GUI_STATE_UPDATE;
98                boardChannel.registerPushConsumer(priority, new PersistentConsumer<Board>()
99                  {
100                          public void        push(Board board)
101                          {
102                                  _board = board;
103                                  update();
104                          }
105                  });
106        }
107 
108        public void        setBoardImageChannel(Channel<DrawingAreaHolder> boardImageChannel)
109        {
110                int priority = EventsPriorities.GUI_STATE_UPDATE;
111                boardImageChannel.registerPushConsumer(        priority, 
112                                                                                                new PersistentConsumer<DrawingAreaHolder>()
113                {
114                        public void        push(DrawingAreaHolder holder)
115                        {
116                                if (holder != null)
117                                {
118                                        _imageModel = holder.getDrawingArea().getBoardImageModel();
119                                        _drawBoard = _imageModel.getBoard();
120                                }
121                                else
122                                {
123                                        _imageModel = null;
124                                        _drawBoard = null;
125                                }
126                                update();
127                        }
128                });
129        }
130        
131        public void        setAccountChannel(Channel<Account> accountChannel)
132        {
133                int priority = EventsPriorities.GUI_STATE_UPDATE;
134                accountChannel.registerPushConsumer(priority, new PersistentConsumer<Account>()
135                {
136                        public void        push(Account account)
137                        {
138                                _account = account;
139                                update();
140                        }
141                });
142        }
143 
144        public void        setEventChannel(Channel<Event> eventsChannel)
145        {
146                int priority = EventsPriorities.GUI_STATE_UPDATE;
147                Filter<Event> filter = new Filter<Event>()
148                {
149                        public boolean        passEvent(Event event)
150                        {
151                                switch (event.getType())
152                                {
153                                        case EVT_MODIFY_BOARD:
154                                        case EVT_JOIN_BOARD:
155                                        case EVT_LEAVE_BOARD:
156                                        case EVT_GIVE_TOKEN:
157                                        return (        (_board != null)
158                                                        &&        (_board.getId() == event.getWhere()));
159 
160                                        default:
161                                        return false;
162                                }
163                        }
164                };
165                eventsChannel.registerPushConsumer(priority, filter, new PersistentDeferredConsumer()
166                {
167                        @Override protected void pushEvent(Event event)
168                        {
169                                update();
170                        }
171                });
172        }
173 
174        public Account        getIdentity()
175        {
176                return _identity.getIdentity();
177        }
178        
179        public Account        getAccount()
180        {
181                return _account;
182        }
183        
184        public Board        getBoard()
185        {
186                return _board;
187        }
188        
189        public BoardImageModel        getImageModel()
190        {
191                return _imageModel;
192        }
193        
194        public Board        getDrawBoard()
195        {
196                return _drawBoard;
197        }
198        
199        public Participant        getParticipant()
200        {
201                return _participant;
202        }
203        
204        public Event        getNotification()
205        {
206                return _notification;
207        }
208 
209        protected void        update()
210        {
211                for (GuiContextListener listener: _listeners.getListeners(GuiContextListener.class))
212                {
213                        listener.contextChanged(this);
214                }
215        }
216        
217        private Account                                _account                = null;
218        private Board                                _board                        = null;
219        private BoardImageModel                _imageModel                = null;
220        private Board                                _drawBoard                = null;
221        private Participant                        _participant        = null;
222        private Event                                _notification        = null;
223        private IdentityHolder                _identity                = null;
224        private EventListenerList        _listeners                = new EventListenerList();
225}

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