Skip to content

Commit 74f59c2

Browse files
bitroncmaglie
authored andcommitted
Changed UserNotifier from interface to abstract class.
1 parent bff6f28 commit 74f59c2

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

app/src/processing/app/helpers/BasicUserNotifier.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
import static processing.app.I18n._;
44

5-
public class BasicUserNotifier implements UserNotifier {
6-
7-
public void showError(String title, String message, Throwable e) {
8-
showError(title, message, e, 1);
9-
}
5+
public class BasicUserNotifier extends UserNotifier {
106

117
/**
128
* Show an error message that's actually fatal to the program.
@@ -28,4 +24,15 @@ public void showMessage(String title, String message) {
2824
System.out.println(title + ": " + message);
2925
}
3026

27+
/**
28+
* Non-fatal error message with optional stack trace side dish.
29+
*/
30+
public void showWarning(String title, String message, Exception e) {
31+
if (title == null) title = _("Warning");
32+
33+
System.out.println(title + ": " + message);
34+
35+
if (e != null) e.printStackTrace();
36+
}
37+
3138
}

app/src/processing/app/helpers/GUIUserNotifier.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66

77
import javax.swing.JOptionPane;
88

9-
public class GUIUserNotifier implements UserNotifier {
10-
11-
public void showError(String title, String message, Throwable e) {
12-
showError(title, message, e, 1);
13-
}
9+
public class GUIUserNotifier extends UserNotifier {
1410

1511
/**
1612
* Show an error message that's actually fatal to the program.
@@ -38,4 +34,16 @@ public void showMessage(String title, String message) {
3834
JOptionPane.INFORMATION_MESSAGE);
3935
}
4036

37+
/**
38+
* Non-fatal error message with optional stack trace side dish.
39+
*/
40+
public void showWarning(String title, String message, Exception e) {
41+
if (title == null) title = _("Warning");
42+
43+
JOptionPane.showMessageDialog(new Frame(), message, title,
44+
JOptionPane.WARNING_MESSAGE);
45+
46+
if (e != null) e.printStackTrace();
47+
}
48+
4149
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
package processing.app.helpers;
22

3-
public interface UserNotifier {
3+
public abstract class UserNotifier {
44

5-
public void showError(String title, String message, Throwable e);
5+
public void showError(String title, String message, int exit_code) {
6+
showError(title, message, null, exit_code);
7+
}
68

7-
public void showError(String title, String message, Throwable e, int exit_code);
9+
public void showError(String title, String message, Throwable e) {
10+
showError(title, message, e, 1);
11+
}
812

9-
public void showMessage(String title, String message);
13+
public abstract void showError(String title, String message, Throwable e, int exit_code);
14+
15+
public abstract void showMessage(String title, String message);
16+
17+
public abstract void showWarning(String title, String message, Exception e);
1018

1119
}

0 commit comments

Comments
 (0)