| 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.edt.GuiActionRunner.execute; |
| 18 |
|
|
| 19 |
|
import java.awt.*; |
| 20 |
|
import java.util.Collection; |
| 21 |
|
|
| 22 |
|
import org.fest.swing.annotation.RunsInCurrentThread; |
| 23 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 24 |
|
import org.fest.swing.edt.GuiQuery; |
| 25 |
|
import org.fest.util.VisibleForTesting; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@author |
| 31 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 10 |
Complexity Density: 0.42 |
|
| 32 |
|
public class WindowMonitor { |
| 33 |
|
|
| 34 |
|
private final Context context; |
| 35 |
|
private final ContextMonitor contextMonitor; |
| 36 |
|
private final Windows windows; |
| 37 |
|
private final WindowStatus windowStatus; |
| 38 |
|
private final WindowAvailabilityMonitor windowAvailabilityMonitor; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@param |
| 48 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
621
|
@RunsInCurrentThread... |
| 50 |
|
WindowMonitor(Toolkit toolkit) { |
| 51 |
621
|
this(toolkit, new Context(toolkit), new WindowStatus(new Windows())); |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 54 |
627
|
@VisibleForTesting... |
| 55 |
|
@RunsInCurrentThread |
| 56 |
|
WindowMonitor(Toolkit toolkit, Context context, WindowStatus windowStatus) { |
| 57 |
627
|
this.context = context; |
| 58 |
627
|
this.windowStatus = windowStatus; |
| 59 |
627
|
windows = windowStatus.windows(); |
| 60 |
627
|
contextMonitor = new ContextMonitor(context, windows); |
| 61 |
627
|
contextMonitor.attachTo(toolkit); |
| 62 |
627
|
windowAvailabilityMonitor = new WindowAvailabilityMonitor(windows); |
| 63 |
627
|
windowAvailabilityMonitor.attachTo(toolkit); |
| 64 |
627
|
populateExistingWindows(); |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 67 |
627
|
private void populateExistingWindows() {... |
| 68 |
27
|
for (Frame f : Frame.getFrames()) examine(f); |
| 69 |
|
} |
| 70 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 71 |
29
|
@RunsInCurrentThread... |
| 72 |
|
private void examine(Window w) { |
| 73 |
29
|
windows.attachNewWindowVisibilityMonitor(w); |
| 74 |
2
|
for (Window owned : w.getOwnedWindows()) examine(owned); |
| 75 |
29
|
windows.markExisting(w); |
| 76 |
29
|
context.addContextFor(w); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@param |
| 84 |
|
@return |
| 85 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 86 |
3772
|
public boolean isWindowReady(Window w) {... |
| 87 |
1084
|
if (windows.isReady(w)) return true; |
| 88 |
2688
|
windowStatus.checkIfReady(w); |
| 89 |
2688
|
return false; |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
@param |
| 97 |
|
@return |
| 98 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 99 |
7
|
public EventQueue eventQueueFor(Component c) {... |
| 100 |
7
|
return context.eventQueueFor(c); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
@return |
| 106 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 107 |
1851
|
public Collection<EventQueue> allEventQueues() {... |
| 108 |
1851
|
return context.allEventQueues(); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
@link |
| 114 |
|
@link |
| 115 |
|
@return |
| 116 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 117 |
13531
|
public Collection<Window> rootWindows() {... |
| 118 |
13531
|
return context.rootWindows(); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
@return |
| 124 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 125 |
1203
|
@RunsInEDT... |
| 126 |
|
public static WindowMonitor instance() { |
| 127 |
1203
|
return SingletonLazyLoader.INSTANCE; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
@RunsInEDT |
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 131 |
|
private static class SingletonLazyLoader { |
| 132 |
|
static final WindowMonitor INSTANCE = execute(new GuiQuery<WindowMonitor>() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 133 |
621
|
protected WindowMonitor executeInEDT() throws Throwable {... |
| 134 |
621
|
return new WindowMonitor(Toolkit.getDefaultToolkit()); |
| 135 |
|
} |
| 136 |
|
}); |
| 137 |
|
} |
| 138 |
|
} |