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

COVERAGE SUMMARY FOR SOURCE FILE [DispatchedEvent.java]

nameclass, %method, %block, %line, %
DispatchedEvent.java0%   (0/1)0%   (0/5)0%   (0/117)0%   (0/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DispatchedEvent0%   (0/1)0%   (0/5)0%   (0/117)0%   (0/30)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
DispatchedEvent (Object): void 0%   (0/1)0%   (0/11)0%   (0/4)
findVisibleParent (): Component 0%   (0/1)0%   (0/37)0%   (0/11)
resetCursor (): boolean 0%   (0/1)0%   (0/29)0%   (0/7)
setCursor (): void 0%   (0/1)0%   (0/36)0%   (0/7)

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 
15// Original copyright is held by Nathan Arthur
16// [Java Specialists' Newsletter, Issue #75, 2003-07-29]
17 
18package net.sourceforge.hivegui.autowait;
19 
20import java.awt.Component;
21import java.awt.Cursor;
22import java.awt.MenuComponent;
23import java.awt.MenuContainer;
24 
25import javax.swing.SwingUtilities;
26 
27class DispatchedEvent
28{
29        public DispatchedEvent(Object source)
30        {
31                _source = source;
32        }
33 
34        public void        setCursor()
35        {
36                synchronized (_mutex)
37                {
38                        _parent = findVisibleParent();
39                        if (_parent != null)
40                        {
41                                _lastCursor = (_parent.isCursorSet() ? _parent.getCursor() : null);
42                                _parent.setCursor(WAIT_CURSOR);
43                        }
44                }
45        }
46 
47        public boolean resetCursor()
48        {
49                synchronized (_mutex)
50                {
51                        if (_parent != null)
52                        {
53                                _parent.setCursor(_lastCursor);
54                                _parent = null;
55                                return true;
56                        }
57                        return false;
58                }
59        }
60 
61        private Component        findVisibleParent()
62        {
63                Component result = null;
64                if (_source instanceof Component)
65                {
66                        result = SwingUtilities.getRoot((Component) _source);
67                }
68                else if (_source instanceof MenuComponent)
69                {
70                        MenuContainer mParent = ((MenuComponent) _source).getParent();
71                        if (mParent instanceof Component)
72                        {
73                                result = SwingUtilities.getRoot((Component) mParent);
74                        }
75                }
76                if ((result != null) && result.isVisible())
77                {
78                        return result;
79                }
80                else
81                {
82                        return null;
83                }
84        }
85 
86        static private final Cursor        WAIT_CURSOR = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
87 
88        private final Object        _mutex = new Object();
89        private final Object        _source;
90        private Component                _parent;
91        private Cursor                        _lastCursor;
92}

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