mirror of https://github.com/noisymime/Arduino.git
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 cc.arduino.view.NotificationPopup;
|
||||||
import processing.app.Base;
|
import processing.app.Base;
|
||||||
import processing.app.BaseNoGui;
|
import processing.app.BaseNoGui;
|
||||||
|
import processing.app.Editor;
|
||||||
import processing.app.I18n;
|
import processing.app.I18n;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.HyperlinkListener;
|
import javax.swing.event.HyperlinkListener;
|
||||||
|
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowFocusListener;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import static processing.app.I18n.tr;
|
import static processing.app.I18n.tr;
|
||||||
|
@ -95,8 +99,30 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
notificationPopup = new NotificationPopup(base.getActiveEditor(), hyperlinkListener, text);
|
Editor ed = base.getActiveEditor();
|
||||||
notificationPopup.setVisible(true);
|
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.MouseEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
@ -52,16 +54,18 @@ import javax.swing.WindowConstants;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.event.HyperlinkListener;
|
import javax.swing.event.HyperlinkListener;
|
||||||
|
|
||||||
|
import cc.arduino.Constants;
|
||||||
import processing.app.Theme;
|
import processing.app.Theme;
|
||||||
|
|
||||||
public class NotificationPopup extends JDialog {
|
public class NotificationPopup extends JDialog {
|
||||||
|
|
||||||
|
private Timer autoCloseTimer = new Timer(false);
|
||||||
|
|
||||||
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
|
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
|
||||||
String message) {
|
String message) {
|
||||||
super(parent, false);
|
super(parent, false);
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
setAlwaysOnTop(true);
|
|
||||||
setUndecorated(true);
|
setUndecorated(true);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
|
@ -131,6 +135,17 @@ public class NotificationPopup extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
autoCloseTimer.cancel();
|
||||||
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
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 String LIBRARY_DEVELOPMENT_FLAG_FILE = ".development";
|
||||||
|
|
||||||
public static final long BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD = 60000;
|
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_NONE = "none";
|
||||||
public static final String PROXY_TYPE_AUTO = "auto";
|
public static final String PROXY_TYPE_AUTO = "auto";
|
||||||
|
|
|
@ -3,6 +3,7 @@ ARDUINO 1.6.9
|
||||||
[ide]
|
[ide]
|
||||||
* Catch and report errors during parsing contributed index files
|
* Catch and report errors during parsing contributed index files
|
||||||
* Fixed IDE version color on about dialog box. Thanks @ivanebernal
|
* Fixed IDE version color on about dialog box. Thanks @ivanebernal
|
||||||
|
* The "always-on-top update notification" popup is now less intrusive.
|
||||||
|
|
||||||
[core]
|
[core]
|
||||||
* sam: Allow 3rd party boards that depend on SAM core to use their own
|
* sam: Allow 3rd party boards that depend on SAM core to use their own
|
||||||
|
|
Loading…
Reference in New Issue