| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
package org.fest.swing.monitor; |
| 16 |
|
|
| 17 |
|
import static org.fest.swing.awt.AWT.ownerLessWindows; |
| 18 |
|
import static org.fest.swing.edt.GuiActionRunner.execute; |
| 19 |
|
import static org.fest.util.Collections.list; |
| 20 |
|
|
| 21 |
|
import java.awt.*; |
| 22 |
|
import java.util.*; |
| 23 |
|
|
| 24 |
|
import net.jcip.annotations.GuardedBy; |
| 25 |
|
import net.jcip.annotations.ThreadSafe; |
| 26 |
|
|
| 27 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 28 |
|
import org.fest.swing.edt.GuiQuery; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
|
| 35 |
|
@ThreadSafe |
|
|
|
| 100% |
Uncovered Elements: 0 (42) |
Complexity: 12 |
Complexity Density: 0.4 |
|
| 36 |
|
class Context { |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@GuardedBy("lock") private final WindowEventQueueMapping windowEventQueueMapping; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@GuardedBy("lock") private final EventQueueMapping eventQueueMapping; |
| 43 |
|
|
| 44 |
|
private final Object lock = new Object(); |
| 45 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
621
|
Context(Toolkit toolkit) {... |
| 47 |
621
|
this(toolkit, new WindowEventQueueMapping(), new EventQueueMapping()); |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 50 |
627
|
Context(Toolkit toolkit, WindowEventQueueMapping windowEventQueueMapping, EventQueueMapping eventQueueMapping) {... |
| 51 |
627
|
this.windowEventQueueMapping = windowEventQueueMapping; |
| 52 |
627
|
this.eventQueueMapping = eventQueueMapping; |
| 53 |
627
|
this.windowEventQueueMapping.addQueueFor(toolkit); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
@link |
| 59 |
|
@link |
| 60 |
|
@return |
| 61 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 62 |
18068
|
Collection<Window> rootWindows() {... |
| 63 |
18068
|
Set<Window> rootWindows = new HashSet<Window>(); |
| 64 |
18068
|
synchronized (lock) { |
| 65 |
18068
|
rootWindows.addAll(windowEventQueueMapping.windows()); |
| 66 |
|
} |
| 67 |
18068
|
rootWindows.addAll(list(Frame.getFrames())); |
| 68 |
18068
|
rootWindows.addAll(list(ownerLessWindows())); |
| 69 |
18068
|
return rootWindows; |
| 70 |
|
} |
| 71 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 72 |
14412
|
EventQueue storedQueueFor(Component c) {... |
| 73 |
14412
|
synchronized (lock) { |
| 74 |
14412
|
return eventQueueMapping.storedQueueFor(c); |
| 75 |
|
} |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 78 |
4516
|
void removeContextFor(Component component) {... |
| 79 |
4516
|
synchronized (lock) { |
| 80 |
4516
|
windowEventQueueMapping.removeMappingFor(component); |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 84 |
3533
|
void addContextFor(Component component) {... |
| 85 |
3533
|
synchronized (lock) { |
| 86 |
3533
|
windowEventQueueMapping.addQueueFor(component); |
| 87 |
3533
|
eventQueueMapping.addQueueFor(component); |
| 88 |
|
} |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
@link |
| 94 |
|
|
| 95 |
|
@param |
| 96 |
|
@return |
| 97 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 98 |
7
|
@RunsInEDT... |
| 99 |
|
EventQueue eventQueueFor(Component c) { |
| 100 |
7
|
Component component = topParentOf(c); |
| 101 |
7
|
synchronized (lock) { |
| 102 |
7
|
return eventQueueMapping.queueFor(component); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 106 |
7
|
@RunsInEDT... |
| 107 |
|
private static Component topParentOf(final Component c) { |
| 108 |
7
|
return execute(new GuiQuery<Component>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 109 |
7
|
protected Component executeInEDT() {... |
| 110 |
7
|
Component parent = c; |
| 111 |
|
|
| 112 |
8
|
while (!(parent instanceof java.applet.Applet) && parent.getParent() != null) |
| 113 |
1
|
parent = parent.getParent(); |
| 114 |
7
|
return parent; |
| 115 |
|
} |
| 116 |
|
}); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
@return |
| 122 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 123 |
1851
|
Collection<EventQueue> allEventQueues() {... |
| 124 |
1851
|
Set<EventQueue> eventQueues = new HashSet<EventQueue>(); |
| 125 |
1851
|
synchronized (lock) { |
| 126 |
1851
|
eventQueues.addAll(windowEventQueueMapping.eventQueues()); |
| 127 |
1851
|
eventQueues.addAll(eventQueueMapping.eventQueues()); |
| 128 |
|
} |
| 129 |
1851
|
return eventQueues; |
| 130 |
|
} |
| 131 |
|
} |