From f96f1d321a2f0f3199394bc384a200f1708277b2 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 11 Aug 2016 17:40:19 +0200 Subject: [PATCH] add overloaded method to NotificationPopup to tune autoclose --- .../cc/arduino/view/NotificationPopup.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/cc/arduino/view/NotificationPopup.java b/app/src/cc/arduino/view/NotificationPopup.java index 87a8e3650..2334d6e14 100644 --- a/app/src/cc/arduino/view/NotificationPopup.java +++ b/app/src/cc/arduino/view/NotificationPopup.java @@ -60,10 +60,17 @@ import processing.app.Theme; public class NotificationPopup extends JDialog { private Timer autoCloseTimer = new Timer(false); + private boolean autoClose = true; public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener, String message) { + this(parent, hyperlinkListener, message, true); + } + + public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener, + String message, boolean _autoClose) { super(parent, false); + autoClose = _autoClose; setLayout(new FlowLayout()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setUndecorated(true); @@ -135,17 +142,21 @@ public class NotificationPopup extends JDialog { } public void close() { - autoCloseTimer.cancel(); + if (autoClose) { + 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); + if (autoClose) { + autoCloseTimer.schedule(new TimerTask() { + @Override + public void run() { + close(); + } + }, Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY); + } setVisible(true); } }