Skip to content

Commit 8d7ee63

Browse files
committed
Autoclose notification popup after 10 seconds.
1 parent 1a7eaaf commit 8d7ee63

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

app/src/cc/arduino/contributions/ContributionsSelfCheck.java

+2-2
Original file line numberDiff line numberDiff 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
}

app/src/cc/arduino/view/NotificationPopup.java

+16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import java.awt.event.MouseEvent;
4343
import java.awt.event.WindowAdapter;
4444
import java.awt.event.WindowEvent;
45+
import java.util.Timer;
46+
import java.util.TimerTask;
4547

4648
import javax.swing.ImageIcon;
4749
import javax.swing.JButton;
@@ -52,10 +54,13 @@
5254
import javax.swing.border.LineBorder;
5355
import javax.swing.event.HyperlinkListener;
5456

57+
import cc.arduino.Constants;
5558
import processing.app.Theme;
5659

5760
public 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
}

arduino-core/src/cc/arduino/Constants.java

+1-1
Original file line numberDiff line numberDiff 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";

0 commit comments

Comments
 (0)