File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
arduino-core/src/cc/arduino Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ public void run() {
102102 Editor ed = base .getActiveEditor ();
103103 notificationPopup = new NotificationPopup (ed , hyperlinkListener , text );
104104 if (ed .isFocused ()) {
105- notificationPopup .setVisible ( true );
105+ notificationPopup .begin ( );
106106 return ;
107107 }
108108
@@ -116,7 +116,7 @@ public void windowLostFocus(WindowEvent evt) {
116116
117117 @ Override
118118 public void windowGainedFocus (WindowEvent evt ) {
119- notificationPopup .setVisible ( true );
119+ notificationPopup .begin ( );
120120 for (Editor e : base .getEditors ())
121121 e .removeWindowFocusListener (this );
122122 }
Original file line number Diff line number Diff line change 4242import java .awt .event .MouseEvent ;
4343import java .awt .event .WindowAdapter ;
4444import java .awt .event .WindowEvent ;
45+ import java .util .Timer ;
46+ import java .util .TimerTask ;
4547
4648import javax .swing .ImageIcon ;
4749import javax .swing .JButton ;
5254import javax .swing .border .LineBorder ;
5355import javax .swing .event .HyperlinkListener ;
5456
57+ import cc .arduino .Constants ;
5558import processing .app .Theme ;
5659
5760public class NotificationPopup extends JDialog {
5861
62+ private Timer autoCloseTimer = new Timer (false );
63+
5964 public NotificationPopup (Frame parent , HyperlinkListener hyperlinkListener ,
6065 String message ) {
6166 super (parent , false );
@@ -130,6 +135,17 @@ private void updateLocation(Frame parent) {
130135 }
131136
132137 public void close () {
138+ autoCloseTimer .cancel ();
133139 dispatchEvent (new WindowEvent (this , WindowEvent .WINDOW_CLOSING ));
134140 }
141+
142+ public void begin () {
143+ autoCloseTimer .schedule (new TimerTask () {
144+ @ Override
145+ public void run () {
146+ close ();
147+ }
148+ }, Constants .NOTIFICATION_POPUP_AUTOCLOSE_DELAY );
149+ setVisible (true );
150+ }
135151}
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public class Constants {
4444 public static final String LIBRARY_DEVELOPMENT_FLAG_FILE = ".development" ;
4545
4646 public static final long BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD = 60000 ;
47- public static final int NOTIFICATION_POPUP_AUTOCLOSE_DELAY = 10000 ;
47+ public static final long NOTIFICATION_POPUP_AUTOCLOSE_DELAY = 10000 ;
4848
4949 public static final String PROXY_TYPE_NONE = "none" ;
5050 public static final String PROXY_TYPE_AUTO = "auto" ;
You can’t perform that action at this time.
0 commit comments