Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart9.png 85% of files have more coverage
10   57   6   3.33
6   27   0.6   3
3     2  
1    
 
  WindowAvailabilityMonitor       Line # 33 10 0% 6 2 89.5% 0.8947368
 
No Tests
 
1    /*
2    * Created on Oct 9, 2007
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 @2007-2010 the original author or authors.
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    * Understands an event listener that monitors when a window is ready to receive OS-level event input.
30    *
31    * @author Alex Ruiz
32    */
 
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   
 
39  631 toggle WindowAvailabilityMonitor(Windows windows) {
40  631 this.windows = windows;
41    }
42   
 
43  628 toggle void attachTo(Toolkit toolkit) {
44  628 attachAsWeakEventListener(toolkit, this, EVENT_MASK);
45    }
46   
 
47  5499 toggle @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    }