From 0b8e7922bfc5588147f267b0ae8ae0ba1eb1ed25 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 1 Jun 2015 09:54:46 +0200 Subject: [PATCH] GUIUserNotifier uses active editor as parent component --- app/src/processing/app/Base.java | 4 ++-- app/src/processing/app/helpers/GUIUserNotifier.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index f3011f23b..a5359aa71 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -142,8 +142,6 @@ public class Base { BaseNoGui.initLogger(); initLogger(); - - BaseNoGui.notifier = new GUIUserNotifier(); BaseNoGui.initPlatform(); @@ -270,6 +268,8 @@ public class Base { } public Base(String[] args) throws Exception { + BaseNoGui.notifier = new GUIUserNotifier(this); + String sketchbookPath = BaseNoGui.getSketchbookPath(); // If no path is set, get the default sketchbook folder for this platform diff --git a/app/src/processing/app/helpers/GUIUserNotifier.java b/app/src/processing/app/helpers/GUIUserNotifier.java index de20b7e3f..ec41c5999 100644 --- a/app/src/processing/app/helpers/GUIUserNotifier.java +++ b/app/src/processing/app/helpers/GUIUserNotifier.java @@ -1,5 +1,7 @@ package processing.app.helpers; +import processing.app.Base; + import static processing.app.I18n._; import java.awt.Frame; @@ -8,6 +10,12 @@ import javax.swing.JOptionPane; public class GUIUserNotifier extends UserNotifier { + private final Base base; + + public GUIUserNotifier(Base base) { + this.base = base; + } + /** * Show an error message that's actually fatal to the program. * This is an error that can't be recovered. Use showWarning() @@ -16,7 +24,7 @@ public class GUIUserNotifier extends UserNotifier { public void showError(String title, String message, Throwable e, int exit_code) { if (title == null) title = _("Error"); - JOptionPane.showMessageDialog(new Frame(), message, title, + JOptionPane.showMessageDialog(base.getActiveEditor(), message, title, JOptionPane.ERROR_MESSAGE); if (e != null) e.printStackTrace(); @@ -30,7 +38,7 @@ public class GUIUserNotifier extends UserNotifier { public void showMessage(String title, String message) { if (title == null) title = _("Message"); - JOptionPane.showMessageDialog(new Frame(), message, title, + JOptionPane.showMessageDialog(base.getActiveEditor(), message, title, JOptionPane.INFORMATION_MESSAGE); }