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

COVERAGE SUMMARY FOR SOURCE FILE [ActiveWindowHolder.java]

nameclass, %method, %block, %line, %
ActiveWindowHolder.java0%   (0/1)0%   (0/6)0%   (0/46)0%   (0/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ActiveWindowHolder0%   (0/1)0%   (0/6)0%   (0/46)0%   (0/19)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
ActiveWindowHolder (): void 0%   (0/1)0%   (0/13)0%   (0/5)
eventDispatched (AWTEvent): void 0%   (0/1)0%   (0/14)0%   (0/6)
getActiveWindow (): Window 0%   (0/1)0%   (0/3)0%   (0/1)
init (): void 0%   (0/1)0%   (0/7)0%   (0/3)
instance (): ActiveWindowHolder 0%   (0/1)0%   (0/5)0%   (0/3)

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.component;
16 
17import java.awt.AWTEvent;
18import java.awt.Toolkit;
19import java.awt.Window;
20import java.awt.event.AWTEventListener;
21import java.awt.event.WindowEvent;
22 
23import org.apache.commons.logging.Log;
24import org.apache.commons.logging.LogFactory;
25 
26/**
27 * @author Jean-Francois Poilpret
28 */
29final public class ActiveWindowHolder implements AWTEventListener
30{
31        static final private Log        _logger = LogFactory.getLog(ActiveWindowHolder.class);
32 
33        // Call this method once before showing any window
34        static synchronized public void                init()
35        {
36                if (_instance == null)
37                {
38                        _instance = new ActiveWindowHolder();
39                }
40        }
41        
42        static public ActiveWindowHolder        instance()
43        {
44                if (_instance == null)
45                {
46                        init();
47                }
48                return _instance;
49        }
50        
51        public Window        getActiveWindow()
52        {
53                return _current;
54        }
55 
56        private ActiveWindowHolder()
57        {
58                _logger.debug("<init>");
59                _current = null;
60                Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.WINDOW_EVENT_MASK);
61        }
62        
63        public void        eventDispatched(AWTEvent e)
64        {
65                switch (e.getID())
66                {
67                        case WindowEvent.WINDOW_ACTIVATED:
68                        _current = ((WindowEvent) e).getWindow();
69                        break;
70 
71                        case WindowEvent.WINDOW_DEACTIVATED:
72                        _current = null;
73                        break;
74                        
75                        default:
76                        // Do nothing (we are only interested in activation events)
77                        break;
78                }
79        }
80        
81        private Window        _current;        
82        static private ActiveWindowHolder        _instance;
83}

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