mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Merge branch 'fix-annoying-popup'
This commit is contained in:
commit
0c453355f4
@ -36,10 +36,14 @@ import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
|
||||
import cc.arduino.view.NotificationPopup;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.Editor;
|
||||
import processing.app.I18n;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
@ -95,8 +99,30 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
notificationPopup = new NotificationPopup(base.getActiveEditor(), hyperlinkListener, text);
|
||||
notificationPopup.setVisible(true);
|
||||
Editor ed = base.getActiveEditor();
|
||||
notificationPopup = new NotificationPopup(ed, hyperlinkListener, text);
|
||||
if (ed.isFocused()) {
|
||||
notificationPopup.begin();
|
||||
return;
|
||||
}
|
||||
|
||||
// If the IDE is not focused wait until it is focused again to
|
||||
// display the notification, this avoids the annoying side effect
|
||||
// to "steal" the focus from another application.
|
||||
WindowFocusListener wfl = new WindowFocusListener() {
|
||||
@Override
|
||||
public void windowLostFocus(WindowEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowGainedFocus(WindowEvent evt) {
|
||||
notificationPopup.begin();
|
||||
for (Editor e : base.getEditors())
|
||||
e.removeWindowFocusListener(this);
|
||||
}
|
||||
};
|
||||
for (Editor e : base.getEditors())
|
||||
e.addWindowFocusListener(wfl);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
@ -52,16 +54,18 @@ import javax.swing.WindowConstants;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import cc.arduino.Constants;
|
||||
import processing.app.Theme;
|
||||
|
||||
public class NotificationPopup extends JDialog {
|
||||
|
||||
private Timer autoCloseTimer = new Timer(false);
|
||||
|
||||
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
|
||||
String message) {
|
||||
super(parent, false);
|
||||
setLayout(new FlowLayout());
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setAlwaysOnTop(true);
|
||||
setUndecorated(true);
|
||||
setResizable(false);
|
||||
|
||||
@ -131,6 +135,17 @@ public class NotificationPopup extends JDialog {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
autoCloseTimer.cancel();
|
||||
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
|
||||
public void begin() {
|
||||
autoCloseTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
close();
|
||||
}
|
||||
}, Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY);
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class Constants {
|
||||
public static final String LIBRARY_DEVELOPMENT_FLAG_FILE = ".development";
|
||||
|
||||
public static final long BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD = 60000;
|
||||
public static final int NOTIFICATION_POPUP_AUTOCLOSE_DELAY = 10000;
|
||||
public static final long NOTIFICATION_POPUP_AUTOCLOSE_DELAY = 10000;
|
||||
|
||||
public static final String PROXY_TYPE_NONE = "none";
|
||||
public static final String PROXY_TYPE_AUTO = "auto";
|
||||
|
@ -3,6 +3,7 @@ ARDUINO 1.6.9
|
||||
[ide]
|
||||
* Catch and report errors during parsing contributed index files
|
||||
* Fixed IDE version color on about dialog box. Thanks @ivanebernal
|
||||
* The "always-on-top update notification" popup is now less intrusive.
|
||||
|
||||
[core]
|
||||
* sam: Allow 3rd party boards that depend on SAM core to use their own
|
||||
|
Loading…
x
Reference in New Issue
Block a user