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

COVERAGE SUMMARY FOR SOURCE FILE [Quit.java]

nameclass, %method, %block, %line, %
Quit.java100% (1/1)100% (3/3)98%  (78/80)100% (15.9/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Quit100% (1/1)100% (3/3)98%  (78/80)100% (15.9/16)
canExit (EventObject): boolean 100% (1/1)97%  (74/76)99%  (13.9/14)
Quit (): void 100% (1/1)100% (3/3)100% (1/1)
willExit (EventObject): void 100% (1/1)100% (1/1)100% (1/1)

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.EventObject;
18 
19import org.jdesktop.application.Application.ExitListener;
20 
21import net.sourceforge.hiveboard.Board;
22import net.sourceforge.hiveboard.util.TokenSetterHelper;
23import net.sourceforge.hivegui.message.UserChoice;
24 
25/**
26 * @author Jean-Francois Poilpret
27 */
28public class Quit extends AbstractCommandHolder implements ExitListener
29{
30        public boolean canExit(EventObject event)
31        {
32                // First check if current user should first give board token to someone else
33                int self = _guiContext.getIdentity().getId();
34                int numOpenBoards = 0;
35                int numGiveTokenBoards = 0;
36                int numInitializerBoards = 0;
37                for (Board board: _repository.getBoards())
38                {
39                        if (board.getPresents().contains(self))
40                        {
41                                numOpenBoards++;
42                                if (TokenSetterHelper.shouldGiveToken(board, self))
43                                {
44                                        numGiveTokenBoards++;
45                                        if (board.getInitiator() == self)
46                                        {
47                                                numInitializerBoards++;
48                                        }
49                                }
50                        }
51                }
52                if (numGiveTokenBoards > 0)
53                {
54                        return (showMessage("confirm-quit", 
55                                                                numOpenBoards,
56                                                                numGiveTokenBoards,
57                                                                numInitializerBoards) == UserChoice.YES);
58                }
59                else
60                {
61                        return true;
62                }
63        }
64 
65        public void willExit(EventObject event)
66        {
67        }
68}

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