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
16   65   8   3.2
6   35   0.5   5
5     1.6  
1    
 
  EventQueueMapping       Line # 31 16 0% 8 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 java.awt.Component;
19    import java.awt.EventQueue;
20    import java.lang.ref.WeakReference;
21    import java.util.*;
22   
23    import org.fest.swing.annotation.RunsInCurrentThread;
24   
25    /**
26    * Understands a mapping of <code>{@link Component}</code>s and their respective <code>{@link EventQueue}</code>.
27    *
28    * @author Yvonne Wang
29    * @author Alex Ruiz
30    */
 
31    class EventQueueMapping {
32   
33    final Map<Component, WeakReference<EventQueue>> queueMap = new WeakHashMap<Component, WeakReference<EventQueue>>();
34   
 
35  3538 toggle @RunsInCurrentThread
36    void addQueueFor(Component c) {
37  3538 EventQueue queue = c.getToolkit().getSystemEventQueue();
38  3538 queueMap.put(c, new WeakReference<EventQueue>(queue));
39    }
40   
 
41  8 toggle @RunsInCurrentThread
42    EventQueue queueFor(Component c) {
43  8 EventQueue queue = storedQueueFor(c);
44  1 if (queue == null) return c.getToolkit().getSystemEventQueue();
45  7 return queue;
46    }
47   
 
48  14422 toggle EventQueue storedQueueFor(Component c) {
49  14422 return queueFrom(queueMap.get(c));
50    }
51   
 
52  1852 toggle Collection<EventQueue> eventQueues() {
53  1852 Set<EventQueue> eventQueues = new HashSet<EventQueue>();
54  1852 for (WeakReference<EventQueue> reference : queueMap.values()) {
55  14941 EventQueue queue = queueFrom(reference);
56  14940 if (queue != null) eventQueues.add(queue);
57    }
58  1852 return eventQueues;
59    }
60   
 
61  29363 toggle private EventQueue queueFrom(WeakReference<EventQueue> reference) {
62  2222 if (reference == null) return null;
63  27141 return reference.get();
64    }
65    }