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

COVERAGE SUMMARY FOR SOURCE FILE [HiveBoardViewFactory.java]

nameclass, %method, %block, %line, %
HiveBoardViewFactory.java100% (3/3)100% (7/7)100% (154/154)100% (34/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HiveBoardViewFactory100% (1/1)100% (3/3)100% (117/117)100% (25/25)
HiveBoardViewFactory (Action, Channel): void 100% (1/1)100% (24/24)100% (7/7)
initView (View, String): void 100% (1/1)100% (34/34)100% (10/10)
setViewTitles (View): void 100% (1/1)100% (59/59)100% (8/8)
     
class HiveBoardViewFactory$1100% (1/1)100% (2/2)100% (20/20)100% (4/4)
HiveBoardViewFactory$1 (HiveBoardViewFactory): void 100% (1/1)100% (6/6)100% (1/1)
passEvent (Event): boolean 100% (1/1)100% (14/14)100% (3/3)
     
class HiveBoardViewFactory$2100% (1/1)100% (2/2)100% (17/17)100% (5/5)
HiveBoardViewFactory$2 (HiveBoardViewFactory): void 100% (1/1)100% (6/6)100% (1/1)
pushEvent (Event): void 100% (1/1)100% (11/11)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.docking;
16 
17import javax.swing.Action;
18 
19import org.flexdock.view.View;
20import org.jdesktop.application.ResourceMap;
21 
22import net.sourceforge.hiveboard.Board;
23import net.sourceforge.hiveboard.Event;
24import net.sourceforge.hiveboard.EventType;
25import net.sourceforge.hiveboard.event.EventsPriorities;
26import net.sourceforge.hiveboard.event.PersistentDeferredConsumer;
27import net.sourceforge.hiveboard.view.DrawingAreaPanel;
28import net.sourceforge.hiveevents.Channel;
29import net.sourceforge.hiveevents.Consumer;
30import net.sourceforge.hiveevents.Filter;
31import net.sourceforge.hivegui.docking.DefaultViewFactory;
32 
33public class HiveBoardViewFactory extends DefaultViewFactory
34{
35        public HiveBoardViewFactory(Action leaveBoardAction, Channel<Event> eventChannel)
36        {
37                _action = leaveBoardAction;
38                // Add consumer to board modifications
39                int priority = EventsPriorities.BOARD_DETAIL_UPDATE;
40                Filter<Event> filter = new Filter<Event>()
41                {
42                        @SuppressWarnings("unchecked")
43                        public boolean passEvent(Event event)
44                        {
45                                // check the event type first
46                                if (event.getType() != EventType.EVT_MODIFY_BOARD)
47                                {
48                                        return false;
49                                }
50                                // check if this board has an open drawing area currently
51                                return ViewHelper.findDrawingArea(event.getWhere()) != null;
52                        }
53                };
54                Consumer<Event> consumer = new PersistentDeferredConsumer()
55                {
56                        @Override protected void pushEvent(Event event)
57                        {
58                                View view = ViewHelper.findDrawingArea(event.getWhere());
59                                if (view != null)
60                                {
61                                        setViewTitles(view);
62                                }
63                        }
64                };
65                eventChannel.registerPushConsumer(priority, filter, consumer);
66        }
67        
68        @Override protected void initView(View view, String id)
69        {
70                // Special processing for board area views
71                if (ViewHelper.isOpenBoardAreaView(id))
72                {
73                        ResourceMap map = _context.getResourceMap(View.class);
74                        
75                        // Trick the resource injection to inject any other properties
76                        view.setName(Views.BOARD_AREA.name());
77                        map.injectComponents(view);
78                        view.setName(id);
79 
80                        // Inject special properties
81                        setViewTitles(view);
82                        view.addAction(new BoardAreaCloseAction(_action));
83                }
84                else
85                {
86                        super.initView(view, id);
87                }
88        }
89        
90        protected void        setViewTitles(View view)
91        {
92                ResourceMap map = _context.getResourceMap(View.class);
93                DrawingAreaPanel content = (DrawingAreaPanel) view.getContentPane();
94                Board board = content.getDrawingArea().getBoardImageModel().getBoard();
95                String key = Views.BOARD_AREA.name() + ".tabText";
96                view.setTabText(map.getString(key, board.getName()));
97                key = Views.BOARD_AREA.name() + ".title";
98                view.setTitle(map.getString(key, board.getName()));
99        }
100        
101        protected final Action        _action;
102}

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