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

COVERAGE SUMMARY FOR SOURCE FILE [CommentListPanel.java]

nameclass, %method, %block, %line, %
CommentListPanel.java100% (4/4)100% (16/16)99%  (284/286)98%  (61/62)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CommentListPanel100% (1/1)100% (10/10)99%  (221/223)98%  (48/49)
sendComment (): Task 100% (1/1)94%  (33/35)88%  (7/8)
CommentListPanel (WhiteBoardUserService, ObjectBuilder, Channel, Channel, Bea... 100% (1/1)100% (107/107)100% (21/21)
access$000 (CommentListPanel, Board): void 100% (1/1)100% (4/4)100% (1/1)
access$100 (CommentListPanel): DataListModel 100% (1/1)100% (3/3)100% (1/1)
access$200 (CommentListPanel): WhiteBoardUserService 100% (1/1)100% (3/3)100% (1/1)
getModel (): DataListModel 100% (1/1)100% (3/3)100% (1/1)
isSendEnabled (): boolean 100% (1/1)100% (3/3)100% (1/1)
setContextHolder (ApplicationContextHolder): void 100% (1/1)100% (18/18)100% (4/4)
setSendEnabled (boolean): void 100% (1/1)100% (12/12)100% (4/4)
updateModel (Board): void 100% (1/1)100% (35/35)100% (9/9)
     
class CommentListPanel$1100% (1/1)100% (2/2)100% (29/29)100% (7/7)
CommentListPanel$1 (CommentListPanel): void 100% (1/1)100% (6/6)100% (1/1)
push (DrawingAreaHolder): void 100% (1/1)100% (23/23)100% (6/6)
     
class CommentListPanel$2100% (1/1)100% (2/2)100% (11/11)100% (3/3)
CommentListPanel$2 (CommentListPanel): void 100% (1/1)100% (6/6)100% (1/1)
push (Object): void 100% (1/1)100% (5/5)100% (2/2)
     
class CommentListPanel$3100% (1/1)100% (2/2)100% (23/23)100% (3/3)
CommentListPanel$3 (CommentListPanel, HiveGuiApplicationMain, int, String): void 100% (1/1)100% (13/13)100% (1/1)
doInBackground (): Void 100% (1/1)100% (10/10)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.awt.BorderLayout;
18 
19import javax.swing.ActionMap;
20import javax.swing.JPanel;
21import javax.swing.JScrollPane;
22import javax.swing.JTextField;
23 
24import org.jdesktop.application.Action;
25import org.jdesktop.application.Task;
26 
27import net.sourceforge.hiveboard.Board;
28import net.sourceforge.hiveboard.Event;
29import net.sourceforge.hiveboard.WhiteBoardUserService;
30import net.sourceforge.hiveboard.command.AbstractTask;
31import net.sourceforge.hiveboard.docking.Views;
32import net.sourceforge.hiveboard.event.EventsPriorities;
33import net.sourceforge.hiveevents.Channel;
34import net.sourceforge.hiveevents.PersistentConsumer;
35import net.sourceforge.hivegui.application.ApplicationContextHolder;
36import net.sourceforge.hivegui.application.HiveGuiApplicationMain;
37import net.sourceforge.hivegui.table.BeanTable;
38import net.sourceforge.hivegui.table.DataListModel;
39import net.sourceforge.hiveutils.service.ObjectBuilder;
40 
41public class CommentListPanel extends JPanel
42{
43        public CommentListPanel(        WhiteBoardUserService                service,
44                                                                ObjectBuilder                                builder,
45                                                                Channel<DrawingAreaHolder>        selectedBoardChannel,
46                                                                Channel<Object>                                clearCommentsChannel,
47                                                                BeanTable<Event>                        tblComments)
48        {
49                setLayout(new BorderLayout());
50                _service = service;
51                _builder = builder;
52                _tblComments = tblComments;
53                _tblComments.setName(Views.COMMENTS_LIST.id() + "-table");
54                _emptyModel = _tblComments.getDataListModel();
55                _model = _emptyModel;
56 
57                // Listen to changes in the current Board
58                int priority = EventsPriorities.SELECTED_IMAGE_GUI_REFRESH;
59                selectedBoardChannel.registerPushConsumer(
60                                                priority, new PersistentConsumer<DrawingAreaHolder>()
61                {
62                        public void        push(DrawingAreaHolder holder)
63                        {
64                                if (holder != null)
65                                {
66                                        updateModel(holder.getDrawingArea().getBoardImageModel().getBoard());
67                                }
68                                else
69                                {
70                                        updateModel(null);
71                                }
72                                setSendEnabled(holder != null);
73                        }
74                });
75 
76                priority = EventsPriorities.COMMENTS_LIST_CLEARED;
77                clearCommentsChannel.registerPushConsumer(priority, new PersistentConsumer<Object>()
78                {
79                        public void        push(Object e)
80                        {
81                                _model.clear();
82                        }
83                });
84 
85                JScrollPane scroller = new JScrollPane(_tblComments);
86                scroller.setName(Views.COMMENTS_LIST.id() + "-scroller");
87            add(scroller, BorderLayout.CENTER);
88 
89                _txfComment = new JTextField();
90                _txfComment.setName(Views.COMMENTS_LIST.id() + "-input");
91            add(_txfComment, BorderLayout.NORTH);
92        }
93 
94        public void        setContextHolder(ApplicationContextHolder holder)
95        {
96                _application = holder.getApplication();
97                // Initialize action
98                ActionMap actionMap = holder.getContext().getActionMap(getClass(), this);
99                _txfComment.setAction(actionMap.get("sendComment"));
100        }
101 
102        @Action(enabledProperty = "sendEnabled", block = Task.BlockingScope.WINDOW)
103        public Task        sendComment()
104        {
105                if (_board == null)
106                {
107                        return null;
108                }
109                final String text = _txfComment.getText();
110                // Clear previous content
111                _txfComment.setText("");
112                if (text == null || text.trim().equals(""))
113                {
114                        return null;
115                }
116                final int id = _board.getId();
117                return new AbstractTask<Void, Void>(_application)
118                {
119                        @Override protected Void doInBackground() throws Exception
120                        {
121                                _service.comment(id, text);
122                                return null;
123                        }
124                };
125        }
126        
127        public DataListModel<Event>        getModel()
128        {
129                return _model;
130        }
131        
132        private void        updateModel(Board board)
133        {
134                if (_board == board)
135                {
136                        return;
137                }
138                _board = board;
139                if (board != null)
140                {
141                        _model = _builder.create("CommentListModel", _board);
142                }
143                else
144                {
145                        _model = _emptyModel;
146                }
147                _tblComments.setDataListModel(_model);
148        }
149 
150        // Utility property that can be used for automatic enabling of accept button
151        final public boolean        isSendEnabled()
152        {
153                return _enabled;
154        }
155        
156        final public void                setSendEnabled(boolean enabled)
157        {
158                boolean old = _enabled;
159                _enabled = enabled;
160                firePropertyChange("sendEnabled", old, enabled);
161        }
162        
163        final private WhiteBoardUserService        _service;
164        final private ObjectBuilder                        _builder;
165        final private BeanTable<Event>                _tblComments;
166        final private JTextField                        _txfComment;
167        final private DataListModel<Event>        _emptyModel;
168        private HiveGuiApplicationMain                _application;
169        private DataListModel<Event>                _model;
170        private Board                                                _board = null;
171        private boolean                                                _enabled = false;
172}

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