KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > AvailableUpdateVisualizerProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.autoupdate;
21
22 import java.awt.Component JavaDoc;
23 import javax.swing.Icon JavaDoc;
24 import javax.swing.ImageIcon JavaDoc;
25 import org.openide.awt.StatusLineElementProvider;
26 import org.openide.util.Utilities;
27
28 /**
29  *
30  * @author Jiri Rechtacek
31  */

32 public final class AvailableUpdateVisualizerProvider implements StatusLineElementProvider {
33
34     public Component JavaDoc getStatusLineElement () {
35         return getUpdatesVisualizer ();
36     }
37
38     private static UpdatesFlasher flasher = null;
39
40     private static Runnable JavaDoc onMouseClick = null;
41
42     /**
43      * Return an icon that is flashing when a new internal exception occurs.
44      * Clicking the icon opens the regular exception dialog box. The icon
45      * disappears (is hidden) after a short period of time and the exception
46      * list is cleared.
47      *
48      * @return A flashing icon component or null if console logging is switched on.
49      */

50     private static Component JavaDoc getUpdatesVisualizer () {
51         if (null == flasher) {
52             ImageIcon JavaDoc img1 = new ImageIcon JavaDoc (Utilities.loadImage ("org/netbeans/modules/autoupdate/resources/newUpdates.gif", false));
53             assert img1 != null : "Icon cannot be null.";
54             flasher = new UpdatesFlasher (img1);
55         }
56         return flasher;
57     }
58     
59     static UpdatesFlasher getFlasher (Runnable JavaDoc whatRunOnMouseClick) {
60         onMouseClick = whatRunOnMouseClick;
61         return flasher;
62     }
63     
64     static class UpdatesFlasher extends FlashingIcon {
65         public UpdatesFlasher (Icon JavaDoc img1) {
66             super (img1);
67             DISAPPEAR_DELAY_MILLIS = -1;
68             // don't flashing by http://ui.netbeans.org/docs/ui/AutoUpdate/AutoUpdate.html
69
STOP_FLASHING_DELAY = 0;
70         }
71
72         /**
73          * User clicked the flashing icon, display the exception window.
74          */

75         protected void onMouseClick () {
76             if (onMouseClick != null) {
77                 onMouseClick.run ();
78                 disappear ();
79             }
80         }
81         
82         /**
83          * The flashing icon disappeared (timed-out), clear the current
84          * exception list.
85          */

86         protected void timeout () {}
87     }
88     
89 }
90
Popular Tags