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

COVERAGE SUMMARY FOR SOURCE FILE [BoardCommands.java]

nameclass, %method, %block, %line, %
BoardCommands.java100% (8/8)100% (31/31)99%  (449/454)99%  (71/72)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BoardCommands100% (1/1)100% (15/15)98%  (255/260)98%  (42/43)
confirmLeaveBoard (): Task 100% (1/1)88%  (38/43)86%  (6/7)
BoardCommands (): void 100% (1/1)100% (3/3)100% (1/1)
createBoard (): void 100% (1/1)100% (7/7)100% (2/2)
createLeaveBoardTask (int): Task 100% (1/1)100% (8/8)100% (1/1)
destroyBoard (): Task 100% (1/1)100% (29/29)100% (4/4)
getCommentsModel (): DataListModel 100% (1/1)100% (17/17)100% (3/3)
getParamsPanel (): LoadCommentsParamsPanel 100% (1/1)100% (14/14)100% (1/1)
joinBoard (): Task 100% (1/1)100% (13/13)100% (2/2)
leaveBoard (): Task 100% (1/1)100% (28/28)100% (4/4)
listSnapshots (): Task 100% (1/1)100% (12/12)100% (2/2)
loadComments (): Task 100% (1/1)100% (34/34)100% (8/8)
modifyBoard (): void 100% (1/1)100% (13/13)100% (2/2)
modifyParticipants (): void 100% (1/1)100% (13/13)100% (2/2)
requestToken (): Task 100% (1/1)100% (13/13)100% (2/2)
takeSnapshot (): Task 100% (1/1)100% (13/13)100% (2/2)
     
class BoardCommands$1100% (1/1)100% (2/2)100% (18/18)100% (3/3)
BoardCommands$1 (BoardCommands, HiveGuiApplicationMain, int): void 100% (1/1)100% (10/10)100% (1/1)
doInBackground (): Void 100% (1/1)100% (8/8)100% (2/2)
     
class BoardCommands$2100% (1/1)100% (3/3)100% (37/37)100% (4/4)
BoardCommands$2 (BoardCommands, HiveGuiApplicationMain, Board): void 100% (1/1)100% (10/10)100% (1/1)
doInBackground (): Snapshot [] 100% (1/1)100% (8/8)100% (1/1)
succeeded (Snapshot []): void 100% (1/1)100% (19/19)100% (2/2)
     
class BoardCommands$3100% (1/1)100% (2/2)100% (18/18)100% (3/3)
BoardCommands$3 (BoardCommands, HiveGuiApplicationMain, int): void 100% (1/1)100% (10/10)100% (1/1)
doInBackground (): Void 100% (1/1)100% (8/8)100% (2/2)
     
class BoardCommands$4100% (1/1)100% (2/2)100% (18/18)100% (3/3)
BoardCommands$4 (BoardCommands, HiveGuiApplicationMain, int): void 100% (1/1)100% (10/10)100% (1/1)
doInBackground (): Void 100% (1/1)100% (8/8)100% (2/2)
     
class BoardCommands$5100% (1/1)100% (2/2)100% (18/18)100% (3/3)
BoardCommands$5 (BoardCommands, HiveGuiApplicationMain, int): void 100% (1/1)100% (10/10)100% (1/1)
doInBackground (): Void 100% (1/1)100% (8/8)100% (2/2)
     
class BoardCommands$6100% (1/1)100% (3/3)100% (67/67)100% (10/10)
BoardCommands$6 (BoardCommands, HiveGuiApplicationMain, Date, Date, Event [],... 100% (1/1)100% (19/19)100% (1/1)
doInBackground (): List 100% (1/1)100% (39/39)100% (7/7)
succeeded (List): void 100% (1/1)100% (9/9)100% (2/2)
     
class BoardCommands$7100% (1/1)100% (2/2)100% (18/18)100% (3/3)
BoardCommands$7 (BoardCommands, HiveGuiApplicationMain, int): void 100% (1/1)100% (10/10)100% (1/1)
doInBackground (): Void 100% (1/1)100% (8/8)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.command;
16 
17import java.util.ArrayList;
18import java.util.Collections;
19import java.util.Date;
20import java.util.List;
21 
22import org.jdesktop.application.Action;
23import org.jdesktop.application.Task;
24 
25import net.sourceforge.hiveboard.Board;
26import net.sourceforge.hiveboard.Event;
27import net.sourceforge.hiveboard.Snapshot;
28import net.sourceforge.hiveboard.dialog.LoadCommentsParamsPanel;
29import net.sourceforge.hiveboard.docking.Views;
30import net.sourceforge.hiveboard.util.TokenSetterHelper;
31import net.sourceforge.hiveboard.view.CommentListPanel;
32import net.sourceforge.hivegui.message.UserChoice;
33import net.sourceforge.hivegui.table.DataListModel;
34 
35public class BoardCommands extends AbstractCommandHolder
36{
37        @Action(enabledProperty = SELF_INITIATOR)
38        public void        createBoard()
39        {
40                showDialog("create-board-panel");
41        }
42        
43        @Action(enabledProperty = BOARD_INITIATOR)
44        public void        modifyBoard()
45        {
46                showDialog("modify-board-panel", _guiContext.getBoard());
47        }
48        
49        @Action(enabledProperty = BOARD_INITIATOR)
50        public void        modifyParticipants()
51        {
52                showDialog("add-participant-panel", _guiContext.getBoard());
53        }
54 
55        @Action(enabledProperty = BOARD_DESTROYABLE, block = Task.BlockingScope.WINDOW)
56        public Task        destroyBoard()
57        {
58                if (showMessage("confirm-destroy-board", 
59                                                _guiContext.getBoard().getName()) == UserChoice.YES)
60                {
61                        final int id = _guiContext.getBoard().getId();
62                        return new AbstractTask<Void, Void>(_application)
63                        {
64                                @Override protected Void doInBackground() throws Exception
65                                {
66                                        _service.closeBoard(id);
67                                        return null;
68                                }
69                        };
70                }
71                else
72                {
73                        return null;
74                }
75        }
76 
77        @Action(enabledProperty = BOARD_SELECTED, block = Task.BlockingScope.WINDOW)
78        public Task        listSnapshots()
79        {
80                final Board board = _guiContext.getBoard();
81                return new AbstractTask<Snapshot[], Void>(_application)
82                {
83                        @Override protected Snapshot[] doInBackground() throws Exception
84                        {
85                                return _service.getSnapshots(board.getId());
86                        }
87 
88                        @Override protected void succeeded(Snapshot[] snapshots)
89                        {
90                                showDialog("list-snapshots-panel", _guiContext.getBoard(), snapshots);
91                        }
92                };
93        }
94        
95        @Action(enabledProperty = ABSENT_FROM_BOARD, block = Task.BlockingScope.WINDOW)
96        public Task        joinBoard()
97        {
98                final int id = _guiContext.getBoard().getId();
99                return new AbstractTask<Void, Void>(_application)
100                {
101                        @Override protected Void doInBackground() throws Exception
102                        {
103                                _service.join(id);
104                                return null;
105                        }
106                };
107        }
108        
109        @Action(enabledProperty = TOKEN_REQUESTABLE, block = Task.BlockingScope.WINDOW)
110        public Task        requestToken()
111        {
112                final int id = _guiContext.getDrawBoard().getId();
113                return new AbstractTask<Void, Void>(_application)
114                {
115                        @Override protected Void doInBackground() throws Exception
116                        {
117                                _service.requestToken(id);
118                                return null;
119                        }
120                };
121        }
122        
123        @Action(enabledProperty = DRAW_BOARD_INITIATOR, block = Task.BlockingScope.WINDOW)
124        public Task        takeSnapshot()
125        {
126                final int id = _guiContext.getDrawBoard().getId();
127                return new AbstractTask<Void, Void>(_application)
128                {
129                        @Override protected Void doInBackground() throws Exception
130                        {
131                                _service.takeSnapshot(id);
132                                return null;
133                        }
134                };
135        }
136 
137        @Action(enabledProperty = DRAW_BOARD_SELECTED, block = Task.BlockingScope.WINDOW)
138        public Task        loadComments()
139        {
140                // Display dialog to enter from..until dates
141                LoadCommentsParamsPanel paramsPanel = getParamsPanel();
142                if (!_application.showDialog(paramsPanel))
143                {
144                        return null;
145                }
146                // Get all required comments
147                final Date from = paramsPanel.getFromDate();
148                final Date until = paramsPanel.getUntilDate();
149 
150                final DataListModel<Event> model = getCommentsModel();
151                final Event[] currentEvents = model.getRows();
152                return new AbstractTask<List<Event>, Void>(_application)
153                {
154                        @Override protected List<Event> doInBackground()
155                                throws Exception
156                        {
157                                // Change list model of comments
158                                List<Event> comments = new ArrayList<Event>();
159                                Collections.addAll(comments, _service.getBoardComments(
160                                                        _guiContext.getDrawBoard().getId(), from, until));
161                                List<Event> events = new ArrayList<Event>();
162                                Collections.addAll(events, currentEvents);
163                                events.removeAll(comments);
164                                events.addAll(comments);
165                                return events;
166                        }
167 
168                        @Override protected void succeeded(List<Event> events)
169                        {
170                                // Set the new rows for the list model
171                                model.setRows(events.toArray(new Event[events.size()]));
172                        }
173                };
174        }
175        
176        @Action(enabledProperty = DRAW_BOARD_SELECTED, block = Task.BlockingScope.WINDOW)
177        public Task        leaveBoard()
178        {
179                Board board = _guiContext.getDrawBoard();
180                // Check if can give token & there are still present participants
181                if (        TokenSetterHelper.shouldGiveToken(board, _guiContext.getIdentity().getId())
182                        &&        !showDialog("give-token-panel", board))
183                {
184                        // If dialog was cancelled, do nothing at all
185                        return null;
186                }
187                return createLeaveBoardTask(board.getId());
188        }
189 
190        // This action is used when user closes the board area view (not the menu)
191        // Note: for an obscure reason, BlockingScope.WINDOW cannot be used here
192        // because it may lead to hangs (hourglass cursor) after closing board
193        @Action(block = Task.BlockingScope.APPLICATION)
194        public Task        confirmLeaveBoard()
195        {
196                Board board = _guiContext.getDrawBoard();
197 
198                // Check if can give token & there are still present participants
199                if (TokenSetterHelper.shouldGiveToken(board, _guiContext.getIdentity().getId()))
200                {
201                        if (!showDialog("give-token-panel", board))
202                        {
203                                // If dialog was cancelled, do nothing at all
204                                return null;
205                        }
206                }
207                else if (_application.showMessage(
208                                 "confirm-leave-board", board.getName()) == UserChoice.CANCEL)
209                {
210                        // User has cancelled leaving the board, do nothing
211                        return null;
212                }
213                // Leaving board is confirmed
214                return createLeaveBoardTask(board.getId());
215        }
216        
217        protected Task        createLeaveBoardTask(final int board)
218        {
219                return new AbstractTask<Void, Void>(_application)
220                {
221                        @Override protected Void doInBackground() throws Exception
222                        {
223                                _service.leave(board);
224                                return null;
225                        }
226                };
227        }
228 
229        protected DataListModel<Event>        getCommentsModel()
230        {
231                if (_commentsPanel == null)
232                {
233                        _commentsPanel = (CommentListPanel) _builder.create(Views.COMMENTS_LIST.id());
234                }
235                return _commentsPanel.getModel();
236        }
237 
238        protected LoadCommentsParamsPanel        getParamsPanel()
239        {
240                return (LoadCommentsParamsPanel) _builder.create(
241                                        "load-comments-params-panel", _guiContext.getDrawBoard());
242        }
243        
244        protected CommentListPanel                        _commentsPanel;
245}

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