GUIUserNotifier uses active editor as parent component

This commit is contained in:
Federico Fissore 2015-06-01 09:54:46 +02:00
parent 17837197d1
commit 0b8e7922bf
2 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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);
}