Skip to content

Commit 0419b1f

Browse files
committed
change Messages.loge() to Messages.err(), additional cleanup
1 parent 58dc712 commit 0419b1f

26 files changed

+97
-111
lines changed

app/src/processing/app/Base.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static private void createAndShowGUI(String[] args) {
191191
Platform.setLookAndFeel();
192192
Platform.setInterfaceZoom();
193193
} catch (Exception e) {
194-
Messages.loge("Error while setting up the interface", e); //$NON-NLS-1$
194+
Messages.err("Error while setting up the interface", e); //$NON-NLS-1$
195195
}
196196

197197
// long t3 = System.currentTimeMillis();
@@ -315,7 +315,7 @@ static private void checkDriverBug() {
315315
}
316316
}
317317
} catch (Exception e) {
318-
Messages.loge("Problem checking NVIDIA driver", e);
318+
Messages.err("Problem checking NVIDIA driver", e);
319319
}
320320
}).start();
321321
}
@@ -748,19 +748,19 @@ public void rebuildToolList() {
748748
} catch (VerifyError | AbstractMethodError ve) {
749749
System.err.println("\"" + tool.getMenuTitle() + "\" is not " +
750750
"compatible with this version of Processing");
751-
Messages.loge("Incompatible Tool found during tool.init()", ve);
751+
Messages.err("Incompatible Tool found during tool.init()", ve);
752752

753753
} catch (NoSuchMethodError nsme) {
754754
System.err.println("\"" + tool.getMenuTitle() + "\" is not " +
755755
"compatible with this version of Processing");
756756
System.err.println("The " + nsme.getMessage() + " method no longer exists.");
757-
Messages.loge("Incompatible Tool found during tool.init()", nsme);
757+
Messages.err("Incompatible Tool found during tool.init()", nsme);
758758

759759
} catch (NoClassDefFoundError ncdfe) {
760760
System.err.println("\"" + tool.getMenuTitle() + "\" is not " +
761761
"compatible with this version of Processing");
762762
System.err.println("The " + ncdfe.getMessage() + " class is no longer available.");
763-
Messages.loge("Incompatible Tool found during tool.init()", ncdfe);
763+
Messages.err("Incompatible Tool found during tool.init()", ncdfe);
764764

765765
} catch (Error | Exception e) {
766766
System.err.println("An error occurred inside \"" + tool.getMenuTitle() + "\"");
@@ -858,7 +858,7 @@ JMenuItem createToolItem(final Tool tool) { //, Map<String, JMenuItem> toolItems
858858
Messages.showWarning("Tool out of date",
859859
tool.getMenuTitle() + " is not compatible with this version of Processing.\n" +
860860
"Try updating the Mode or contact its author for a new version.", ne);
861-
Messages.loge("Incompatible tool found during tool.run()", ne);
861+
Messages.err("Incompatible tool found during tool.run()", ne);
862862
item.setEnabled(false);
863863

864864
} catch (Exception ex) {

app/src/processing/app/Messages.java

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import javax.swing.JFrame;
3030
import javax.swing.JOptionPane;
3131

32-
import processing.app.ui.Editor;
33-
3432
public class Messages {
3533
/**
3634
* "No cookie for you" type messages. Nothing fatal or all that
@@ -190,26 +188,14 @@ static public void showTrace(String title, String message,
190188

191189

192190

191+
/*
193192
// incomplete
194193
static public int showYesNoCancelQuestion(Editor editor, String title,
195194
String primary, String secondary) {
196195
if (!Platform.isMacOS()) {
197-
int result =
198-
JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
199-
JOptionPane.YES_NO_CANCEL_OPTION,
200-
JOptionPane.QUESTION_MESSAGE);
201-
return result;
202-
// if (result == JOptionPane.YES_OPTION) {
203-
//
204-
// } else if (result == JOptionPane.NO_OPTION) {
205-
// return true; // ok to continue
206-
//
207-
// } else if (result == JOptionPane.CANCEL_OPTION) {
208-
// return false;
209-
//
210-
// } else {
211-
// throw new IllegalStateException();
212-
// }
196+
return JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
197+
JOptionPane.YES_NO_CANCEL_OPTION,
198+
JOptionPane.QUESTION_MESSAGE);
213199
214200
} else {
215201
// Pane formatting adapted from the Quaqua guide
@@ -236,8 +222,7 @@ static public int showYesNoCancelQuestion(Editor editor, String title,
236222
237223
// on macosx, setting the destructive property places this option
238224
// away from the others at the lefthand side
239-
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
240-
Integer.valueOf(2));
225+
pane.putClientProperty("Quaqua.OptionPane.destructiveOption", 2);
241226
242227
JDialog dialog = pane.createDialog(editor, null);
243228
dialog.setVisible(true);
@@ -254,6 +239,7 @@ static public int showYesNoCancelQuestion(Editor editor, String title,
254239
}
255240
}
256241
}
242+
*/
257243

258244

259245
static public int showYesNoQuestion(Frame editor, String title,
@@ -347,19 +333,19 @@ static public void logf(String message, Object... args) {
347333
}
348334

349335

350-
static public void loge(String message, Throwable e) {
351-
if (Base.DEBUG) {
352-
if (message != null) {
353-
System.err.println(message);
354-
}
355-
e.printStackTrace();
356-
}
336+
static public void err(String message) {
337+
err(message, null);
357338
}
358339

359340

360-
static public void loge(String message) {
341+
static public void err(String message, Throwable e) {
361342
if (Base.DEBUG) {
362-
System.err.println(message);
343+
if (message != null) {
344+
System.err.println(message);
345+
}
346+
if (e != null) {
347+
e.printStackTrace();
348+
}
363349
}
364350
}
365351
}

app/src/processing/app/Mode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ public void prepareExportFolder(File targetFolder) {
10231023
// Create a fresh output folder (needed before preproc is run next)
10241024
if (!targetFolder.exists()) {
10251025
if (!targetFolder.mkdirs()) {
1026-
Messages.loge("Could not create " + targetFolder);
1026+
Messages.err("Could not create " + targetFolder);
10271027
}
10281028
}
10291029
}

app/src/processing/app/Settings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void load(File additions) {
8888
}
8989
}
9090
} else {
91-
Messages.loge(additions + " could not be read");
91+
Messages.err(additions + " could not be read");
9292
}
9393

9494
// check for platform-specific properties in the defaults

app/src/processing/app/SingleInstance.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class SingleInstance {
4747
* Returns true if there's an instance of Processing already running.
4848
* Will not return true unless this code was able to successfully
4949
* contact the already running instance to have it launch sketches.
50-
* @param filename Path to the PDE file that was opened, null if double-clicked
5150
* @return true if successfully launched on the other instance
5251
*/
5352
static boolean alreadyRunning(String[] args) {
@@ -108,14 +107,14 @@ public void run() {
108107
}
109108
// }
110109
} catch (IOException e) {
111-
Messages.loge("SingleInstance error while listening", e);
110+
Messages.err("SingleInstance error while listening", e);
112111
}
113112
}
114113
}
115114
}, "SingleInstance Server").start();
116115

117116
} catch (IOException e) {
118-
Messages.loge("Could not create single instance server.", e);
117+
Messages.err("Could not create single instance server.", e);
119118
}
120119
}
121120

@@ -143,7 +142,7 @@ static boolean sendArguments(String[] args) { //, long timeout) {
143142
return true;
144143
}
145144
} catch (IOException e) {
146-
Messages.loge("Error sending commands to other instance", e);
145+
Messages.err("Error sending commands to other instance", e);
147146
}
148147
Messages.log("Processing is not already running (or could not connect)");
149148
return false;

app/src/processing/app/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static public byte[] loadBytesRaw(File file) throws IOException {
7474
*/
7575
static public StringDict readSettings(File inputFile) {
7676
if (!inputFile.exists()) {
77-
Messages.loge(inputFile + " does not exist inside readSettings()");
77+
Messages.err(inputFile + " does not exist inside readSettings()");
7878
return null;
7979
}
8080
String lines[] = PApplet.loadStrings(inputFile);

app/src/processing/app/contrib/ModeContribution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static public ModeContribution load(Base base, File folder,
6666
// For the built-in modes, don't print the exception, just log it
6767
// for debugging. This should be impossible for most users to reach,
6868
// but it helps us load experimental mode when it's available.
69-
Messages.loge("ModeContribution.load() failed for " + searchName, err);
69+
Messages.err("ModeContribution.load() failed for " + searchName, err);
7070
}
7171
}
7272
return null;

app/src/processing/app/syntax/JEditTextArea.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ public void mouseDragged(MouseEvent evt) {
23322332
try {
23332333
select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY()));
23342334
} catch (ArrayIndexOutOfBoundsException e) {
2335-
Messages.loge("xToOffset problem", e);
2335+
Messages.err("xToOffset problem", e);
23362336
}
23372337
} else {
23382338
int line = yToLine(evt.getY());

app/src/processing/app/ui/Editor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2410,7 +2410,7 @@ protected void handleOpenInternal(String path) throws EditorException {
24102410

24112411
// remove the original file, so user doesn't get confused
24122412
if (!origPdeFile.delete()) {
2413-
Messages.loge("Could not delete " + origPdeFile);
2413+
Messages.err("Could not delete " + origPdeFile);
24142414
}
24152415

24162416
// update with the new path

app/src/processing/app/ui/PreferencesFrame.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ public PreferencesFrame(Base base) {
160160
consoleFontSizeField = new JComboBox<>(FONT_SIZES);
161161
consoleFontSizeField.setSelectedItem(Preferences.getInteger("console.font.size"));
162162

163+
// Sizing is screwed up on macOS, bug has been open since 2017
164+
// https://github.com/processing/processing4/issues/232
165+
// https://bugs.openjdk.java.net/browse/JDK-8179076
166+
fontSizeField.setEditable(true);
167+
consoleFontSizeField.setEditable(true);
168+
163169

164170
// Interface scale: [ 100% ] (requires restart of Processing)
165171

@@ -507,23 +513,16 @@ public void windowClosing(WindowEvent e) {
507513
frame.pack();
508514
frame.setLocationRelativeTo(null);
509515

510-
// Workaround for OS X, which breaks the layout when these are set earlier
511-
// https://github.com/processing/processing/issues/3212
512-
fontSizeField.setEditable(true);
513-
consoleFontSizeField.setEditable(true);
514-
515516
// handle window closing commands for ctrl/cmd-W or hitting ESC.
516-
517517
pain.addKeyListener(new KeyAdapter() {
518-
public void keyPressed(KeyEvent e) {
519-
//System.out.println(e);
520-
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
521-
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
522-
(KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
523-
disposeFrame();
524-
}
518+
public void keyPressed(KeyEvent e) {
519+
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
520+
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
521+
(KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
522+
disposeFrame();
525523
}
526-
});
524+
}
525+
});
527526
}
528527

529528

0 commit comments

Comments
 (0)