EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hivegui.docking]

COVERAGE SUMMARY FOR SOURCE FILE [DockingHelper.java]

nameclass, %method, %block, %line, %
DockingHelper.java0%   (0/1)0%   (0/4)0%   (0/116)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DockingHelper0%   (0/1)0%   (0/4)0%   (0/116)0%   (0/21)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
DockingHelper (): void 0%   (0/1)0%   (0/3)0%   (0/2)
selectView (Viewport, String): boolean 0%   (0/1)0%   (0/59)0%   (0/13)
trace (Component, String): void 0%   (0/1)0%   (0/50)0%   (0/5)

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.hivegui.docking;
16 
17import java.awt.Component;
18import java.awt.Container;
19import java.awt.KeyboardFocusManager;
20 
21import javax.swing.JTabbedPane;
22 
23import org.apache.commons.logging.Log;
24import org.apache.commons.logging.LogFactory;
25import org.flexdock.view.View;
26import org.flexdock.view.Viewport;
27 
28public final class DockingHelper
29{
30        static private final Log        _logger = LogFactory.getLog(DockingHelper.class);
31 
32        private DockingHelper()
33        {
34        }
35 
36        static public boolean        selectView(Viewport port, String id)
37        {
38                // Get current focused component
39                KeyboardFocusManager focusManager =
40                                        KeyboardFocusManager.getCurrentKeyboardFocusManager();
41                Component focused = focusManager.getPermanentFocusOwner();
42//                Component focused = focusManager.getFocusOwner();
43                try
44                {
45                        Component docked = port.getDockedComponent();
46                        if (docked instanceof JTabbedPane)
47                        {
48                                JTabbedPane tabs = (JTabbedPane) docked;
49                                for (Component tab: tabs.getComponents())
50                                {
51                                        View view = (View) tab;
52                                        if (view.getPersistentId().equals(id))
53                                        {
54                                                tabs.setSelectedComponent(view);
55                                                return true;
56                                        }
57                                }
58                        }
59                        return false;
60                }
61                finally
62                {
63                        // Restore previously focused component
64                        if (focused != null)
65                        {
66//                                focused.requestFocusInWindow();
67                        }
68                }
69        }
70 
71        static public void        trace(Component comp, String indent)
72        {
73                _logger.debug(indent + comp.getName() + " [" + comp.getClass() + "]");
74                if (comp instanceof Container)
75                {
76                        for (Component child: ((Container) comp).getComponents())
77                        {
78                                trace(child, indent + "  ");
79                        }
80                }
81        }
82}

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