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

COVERAGE SUMMARY FOR SOURCE FILE [AddParticipantPanel.java]

nameclass, %method, %block, %line, %
AddParticipantPanel.java100% (3/3)100% (9/9)100% (155/155)100% (29/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AddParticipantPanel100% (1/1)100% (5/5)100% (102/102)100% (21/21)
AddParticipantPanel (BeanTable, WhiteBoardUserService, Board): void 100% (1/1)100% (46/46)100% (11/11)
accept (): Task 100% (1/1)100% (46/46)100% (7/7)
access$000 (AddParticipantPanel): BeanTable 100% (1/1)100% (3/3)100% (1/1)
access$100 (AddParticipantPanel): WhiteBoardUserService 100% (1/1)100% (3/3)100% (1/1)
reset (): void 100% (1/1)100% (4/4)100% (2/2)
     
class AddParticipantPanel$1100% (1/1)100% (2/2)100% (18/18)100% (3/3)
AddParticipantPanel$1 (AddParticipantPanel): void 100% (1/1)100% (6/6)100% (1/1)
valueChanged (ListSelectionEvent): void 100% (1/1)100% (12/12)100% (2/2)
     
class AddParticipantPanel$2100% (1/1)100% (2/2)100% (35/35)100% (5/5)
AddParticipantPanel$2 (AddParticipantPanel, HiveGuiApplicationMain, GenericDi... 100% (1/1)100% (11/11)100% (1/1)
doInBackground (): Void 100% (1/1)100% (24/24)100% (4/4)

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.dialog;
16 
17import java.awt.BorderLayout;
18import java.util.ArrayList;
19import java.util.List;
20 
21import javax.swing.JScrollPane;
22import javax.swing.event.ListSelectionEvent;
23import javax.swing.event.ListSelectionListener;
24 
25import org.jdesktop.application.Action;
26import org.jdesktop.application.Task;
27 
28import net.sourceforge.hiveboard.Account;
29import net.sourceforge.hiveboard.Board;
30import net.sourceforge.hiveboard.WhiteBoardUserService;
31import net.sourceforge.hiveboard.command.AbstractTask;
32import net.sourceforge.hivegui.table.BeanTable;
33import net.sourceforge.hivegui.table.DataListModel;
34 
35public class AddParticipantPanel extends AbstractBoardPanel
36{
37        static private final String        NAME = "add-participant";
38        
39        public AddParticipantPanel(        BeanTable<Account>                tblAccounts,
40                                                                WhiteBoardUserService        service,
41                                                                Board                                        board)
42        {
43                super(NAME);
44                setLayout(new BorderLayout());
45                _board = board;
46                _service = service;
47                _tblAccounts = tblAccounts;
48                _accounts = _tblAccounts.getDataListModel();
49                
50                _tblAccounts.setName(NAME + "-list");
51 
52                add(new JScrollPane(_tblAccounts), BorderLayout.CENTER);
53 
54                _tblAccounts.clearSelection();
55                _tblAccounts.getSelectionModel().addListSelectionListener(new ListSelectionListener()
56                {
57                        public void        valueChanged(ListSelectionEvent e)
58                        {
59                                setAcceptEnabled(_tblAccounts.getSelectedRowCount() != 0);
60                        }
61                });
62        }
63        
64        @Override public void reset()
65        {
66                setAcceptEnabled(false);
67        }
68 
69        @Action(enabledProperty = "acceptEnabled", block = Task.BlockingScope.WINDOW)
70        public Task accept()
71        {
72                int[] selected = _tblAccounts.getSelectedRows();
73                final List<Account> accounts = new ArrayList<Account>();
74                for (int i = 0; i < selected.length; i++)
75                {
76                        Account account = _accounts.getRow(selected[i]);
77                        if (!_board.getParticipants().contains(account.getId()))
78                        {
79                                accounts.add(account);
80                        }
81                }
82                return new AbstractTask<Void, Void>(_application, _parent)
83                {
84                        @Override protected Void doInBackground() throws Exception
85                        {
86                                for (Account account: accounts)
87                                {
88                                        _service.addParticipant(_board.getId(), account.getId());
89                                }
90                                return null;
91                        }
92                };
93        }
94        
95        final private WhiteBoardUserService                _service;
96        final private BeanTable<Account>                _tblAccounts;
97        final private DataListModel<Account>        _accounts;
98}

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