| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.monitor; |
| 17 |
|
|
| 18 |
|
import static java.awt.AWTEvent.*; |
| 19 |
|
import static javax.swing.SwingUtilities.getWindowAncestor; |
| 20 |
|
import static org.fest.swing.listener.WeakEventListener.attachAsWeakEventListener; |
| 21 |
|
|
| 22 |
|
import java.awt.*; |
| 23 |
|
import java.awt.event.AWTEventListener; |
| 24 |
|
import java.awt.event.MouseEvent; |
| 25 |
|
|
| 26 |
|
import org.fest.swing.annotation.RunsInEDT; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@author |
| 32 |
|
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 6 |
Complexity Density: 0.6 |
|
| 33 |
|
final class WindowAvailabilityMonitor implements AWTEventListener { |
| 34 |
|
|
| 35 |
|
private static final long EVENT_MASK = MOUSE_MOTION_EVENT_MASK | MOUSE_EVENT_MASK | PAINT_EVENT_MASK; |
| 36 |
|
|
| 37 |
|
private final Windows windows; |
| 38 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 39 |
631
|
WindowAvailabilityMonitor(Windows windows) {... |
| 40 |
631
|
this.windows = windows; |
| 41 |
|
} |
| 42 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 43 |
628
|
void attachTo(Toolkit toolkit) {... |
| 44 |
628
|
attachAsWeakEventListener(toolkit, this, EVENT_MASK); |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 47 |
5499
|
@RunsInEDT... |
| 48 |
|
public void eventDispatched(AWTEvent e) { |
| 49 |
1128
|
if (!(e instanceof MouseEvent)) return; |
| 50 |
4371
|
Object source = e.getSource(); |
| 51 |
4371
|
if (!(source instanceof Component)) return; |
| 52 |
4371
|
Component c = (Component) source; |
| 53 |
4371
|
Window w = c instanceof Window ? (Window)c : getWindowAncestor(c); |
| 54 |
4371
|
windows.markAsReady(w); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
} |