mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-18 12:54:25 +01:00
Added notifier interface and classes.
This commit is contained in:
parent
a43d207e4f
commit
fa0d37dad6
25
app/src/processing/app/helpers/BasicNotifier.java
Normal file
25
app/src/processing/app/helpers/BasicNotifier.java
Normal file
@ -0,0 +1,25 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
public class BasicNotifier implements UserNotifier {
|
||||
|
||||
public void showError(String title, String message, Throwable e) {
|
||||
showError(title, message, e, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an error message that's actually fatal to the program.
|
||||
* This is an error that can't be recovered. Use showWarning()
|
||||
* for errors that allow P5 to continue running.
|
||||
*/
|
||||
public void showError(String title, String message, Throwable e, int exit_code) {
|
||||
if (title == null) title = _("Error");
|
||||
|
||||
System.err.println(title + ": " + message);
|
||||
|
||||
if (e != null) e.printStackTrace();
|
||||
System.exit(exit_code);
|
||||
}
|
||||
|
||||
}
|
29
app/src/processing/app/helpers/GUINotifier.java
Normal file
29
app/src/processing/app/helpers/GUINotifier.java
Normal file
@ -0,0 +1,29 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
import java.awt.Frame;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class GUINotifier implements UserNotifier {
|
||||
|
||||
public void showError(String title, String message, Throwable e) {
|
||||
showError(title, message, e, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an error message that's actually fatal to the program.
|
||||
* This is an error that can't be recovered. Use showWarning()
|
||||
* for errors that allow P5 to continue running.
|
||||
*/
|
||||
public void showError(String title, String message, Throwable e, int exit_code) {
|
||||
if (title == null) title = _("Error");
|
||||
|
||||
JOptionPane.showMessageDialog(new Frame(), message, title,
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
if (e != null) e.printStackTrace();
|
||||
System.exit(exit_code);
|
||||
}
|
||||
}
|
9
app/src/processing/app/helpers/UserNotifier.java
Normal file
9
app/src/processing/app/helpers/UserNotifier.java
Normal file
@ -0,0 +1,9 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
public interface UserNotifier {
|
||||
|
||||
public void showError(String title, String message, Throwable e);
|
||||
|
||||
public void showError(String title, String message, Throwable e, int exit_code);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user