Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
23   76   11   3.29
6   43   0.48   7
7     1.57  
1    
 
  WindowEventQueueMapping       Line # 32 23 0% 11 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Mar 22, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. 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 distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.monitor;
17   
18    import static java.lang.Boolean.TRUE;
19    import static org.fest.swing.query.ComponentParentQuery.parentOf;
20   
21    import java.awt.*;
22    import java.util.*;
23   
24    import org.fest.swing.annotation.RunsInCurrentThread;
25   
26    /**
27    * Understands a mapping of unique event queues to the set of root windows found on each queue.
28    *
29    * @author Alex Ruiz
30    * @author Yvonne Wang
31    */
 
32    class WindowEventQueueMapping {
33   
34    final Map<EventQueue, Map<Window, Boolean>> queueMap = new WeakHashMap<EventQueue, Map<Window, Boolean>>();
35   
 
36  622 toggle void addQueueFor(Toolkit toolkit) {
37  622 queueMap.put(toolkit.getSystemEventQueue(), new WeakHashMap<Window, Boolean>());
38    }
39   
 
40  3539 toggle void addQueueFor(Component component) {
41  3539 EventQueue queue = component.getToolkit().getSystemEventQueue();
42  3539 Map<Window, Boolean> windowMapping = queueMap.get(queue);
43  6 if (windowMapping == null) windowMapping = createWindowMapping(queue);
44  633 if (!(component instanceof Window) || parentOf(component) != null) return;
45  2906 windowMapping.put((Window)component, TRUE);
46    }
47   
 
48  6 toggle private Map<Window, Boolean> createWindowMapping(EventQueue queue) {
49  6 Map<Window, Boolean> windowMapping = new WeakHashMap<Window, Boolean>();
50  6 queueMap.put(queue, windowMapping);
51  6 return windowMapping;
52    }
53   
 
54  4517 toggle @RunsInCurrentThread
55    void removeMappingFor(Component component) {
56  4517 EventQueue queue = component.getToolkit().getSystemEventQueue();
57  4517 removeComponent(component, queue);
58  4517 for (EventQueue q : queueMap.keySet()) removeComponent(component, q);
59    }
60   
 
61  9034 toggle private void removeComponent(Component component, EventQueue queue) {
62  9034 Map<Window, Boolean> windowMapping = queueMap.get(queue);
63  9033 if (windowMapping != null) windowMapping.remove(component);
64    }
65   
 
66  18068 toggle Collection<Window> windows() {
67  18068 Set<Window> rootWindows = new HashSet<Window>();
68  18068 for (EventQueue queue : queueMap.keySet())
69  18068 rootWindows.addAll(queueMap.get(queue).keySet());
70  18068 return rootWindows;
71    }
72   
 
73  1851 toggle Collection<EventQueue> eventQueues() {
74  1851 return queueMap.keySet();
75    }
76    }