change Messages.loge() to Messages.err(), additional cleanup

This commit is contained in:
Ben Fry
2021-08-03 20:44:03 -04:00
parent 58dc712232
commit 0419b1ffb2
26 changed files with 97 additions and 111 deletions
+6 -6
View File
@@ -191,7 +191,7 @@ public class Base {
Platform.setLookAndFeel();
Platform.setInterfaceZoom();
} catch (Exception e) {
Messages.loge("Error while setting up the interface", e); //$NON-NLS-1$
Messages.err("Error while setting up the interface", e); //$NON-NLS-1$
}
// long t3 = System.currentTimeMillis();
@@ -315,7 +315,7 @@ public class Base {
}
}
} catch (Exception e) {
Messages.loge("Problem checking NVIDIA driver", e);
Messages.err("Problem checking NVIDIA driver", e);
}
}).start();
}
@@ -748,19 +748,19 @@ public class Base {
} catch (VerifyError | AbstractMethodError ve) {
System.err.println("\"" + tool.getMenuTitle() + "\" is not " +
"compatible with this version of Processing");
Messages.loge("Incompatible Tool found during tool.init()", ve);
Messages.err("Incompatible Tool found during tool.init()", ve);
} catch (NoSuchMethodError nsme) {
System.err.println("\"" + tool.getMenuTitle() + "\" is not " +
"compatible with this version of Processing");
System.err.println("The " + nsme.getMessage() + " method no longer exists.");
Messages.loge("Incompatible Tool found during tool.init()", nsme);
Messages.err("Incompatible Tool found during tool.init()", nsme);
} catch (NoClassDefFoundError ncdfe) {
System.err.println("\"" + tool.getMenuTitle() + "\" is not " +
"compatible with this version of Processing");
System.err.println("The " + ncdfe.getMessage() + " class is no longer available.");
Messages.loge("Incompatible Tool found during tool.init()", ncdfe);
Messages.err("Incompatible Tool found during tool.init()", ncdfe);
} catch (Error | Exception e) {
System.err.println("An error occurred inside \"" + tool.getMenuTitle() + "\"");
@@ -858,7 +858,7 @@ public class Base {
Messages.showWarning("Tool out of date",
tool.getMenuTitle() + " is not compatible with this version of Processing.\n" +
"Try updating the Mode or contact its author for a new version.", ne);
Messages.loge("Incompatible tool found during tool.run()", ne);
Messages.err("Incompatible tool found during tool.run()", ne);
item.setEnabled(false);
} catch (Exception ex) {
+15 -29
View File
@@ -29,8 +29,6 @@ import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import processing.app.ui.Editor;
public class Messages {
/**
* "No cookie for you" type messages. Nothing fatal or all that
@@ -190,26 +188,14 @@ public class Messages {
/*
// incomplete
static public int showYesNoCancelQuestion(Editor editor, String title,
String primary, String secondary) {
if (!Platform.isMacOS()) {
int result =
JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
return result;
// if (result == JOptionPane.YES_OPTION) {
//
// } else if (result == JOptionPane.NO_OPTION) {
// return true; // ok to continue
//
// } else if (result == JOptionPane.CANCEL_OPTION) {
// return false;
//
// } else {
// throw new IllegalStateException();
// }
return JOptionPane.showConfirmDialog(null, primary + "\n" + secondary, title,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
} else {
// Pane formatting adapted from the Quaqua guide
@@ -236,8 +222,7 @@ public class Messages {
// on macosx, setting the destructive property places this option
// away from the others at the lefthand side
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
Integer.valueOf(2));
pane.putClientProperty("Quaqua.OptionPane.destructiveOption", 2);
JDialog dialog = pane.createDialog(editor, null);
dialog.setVisible(true);
@@ -254,6 +239,7 @@ public class Messages {
}
}
}
*/
static public int showYesNoQuestion(Frame editor, String title,
@@ -347,19 +333,19 @@ public class Messages {
}
static public void loge(String message, Throwable e) {
static public void err(String message) {
err(message, null);
}
static public void err(String message, Throwable e) {
if (Base.DEBUG) {
if (message != null) {
System.err.println(message);
}
e.printStackTrace();
}
}
static public void loge(String message) {
if (Base.DEBUG) {
System.err.println(message);
if (e != null) {
e.printStackTrace();
}
}
}
}
+1 -1
View File
@@ -1023,7 +1023,7 @@ public abstract class Mode {
// Create a fresh output folder (needed before preproc is run next)
if (!targetFolder.exists()) {
if (!targetFolder.mkdirs()) {
Messages.loge("Could not create " + targetFolder);
Messages.err("Could not create " + targetFolder);
}
}
}
+1 -1
View File
@@ -88,7 +88,7 @@ public class Settings {
}
}
} else {
Messages.loge(additions + " could not be read");
Messages.err(additions + " could not be read");
}
// check for platform-specific properties in the defaults
+3 -4
View File
@@ -47,7 +47,6 @@ public class SingleInstance {
* Returns true if there's an instance of Processing already running.
* Will not return true unless this code was able to successfully
* contact the already running instance to have it launch sketches.
* @param filename Path to the PDE file that was opened, null if double-clicked
* @return true if successfully launched on the other instance
*/
static boolean alreadyRunning(String[] args) {
@@ -108,14 +107,14 @@ public class SingleInstance {
}
// }
} catch (IOException e) {
Messages.loge("SingleInstance error while listening", e);
Messages.err("SingleInstance error while listening", e);
}
}
}
}, "SingleInstance Server").start();
} catch (IOException e) {
Messages.loge("Could not create single instance server.", e);
Messages.err("Could not create single instance server.", e);
}
}
@@ -143,7 +142,7 @@ public class SingleInstance {
return true;
}
} catch (IOException e) {
Messages.loge("Error sending commands to other instance", e);
Messages.err("Error sending commands to other instance", e);
}
Messages.log("Processing is not already running (or could not connect)");
return false;
+1 -1
View File
@@ -74,7 +74,7 @@ public class Util {
*/
static public StringDict readSettings(File inputFile) {
if (!inputFile.exists()) {
Messages.loge(inputFile + " does not exist inside readSettings()");
Messages.err(inputFile + " does not exist inside readSettings()");
return null;
}
String lines[] = PApplet.loadStrings(inputFile);
@@ -66,7 +66,7 @@ public class ModeContribution extends LocalContribution {
// For the built-in modes, don't print the exception, just log it
// for debugging. This should be impossible for most users to reach,
// but it helps us load experimental mode when it's available.
Messages.loge("ModeContribution.load() failed for " + searchName, err);
Messages.err("ModeContribution.load() failed for " + searchName, err);
}
}
return null;
@@ -2332,7 +2332,7 @@ public class JEditTextArea extends JComponent
try {
select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY()));
} catch (ArrayIndexOutOfBoundsException e) {
Messages.loge("xToOffset problem", e);
Messages.err("xToOffset problem", e);
}
} else {
int line = yToLine(evt.getY());
+1 -1
View File
@@ -2410,7 +2410,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
// remove the original file, so user doesn't get confused
if (!origPdeFile.delete()) {
Messages.loge("Could not delete " + origPdeFile);
Messages.err("Could not delete " + origPdeFile);
}
// update with the new path
+13 -14
View File
@@ -160,6 +160,12 @@ public class PreferencesFrame {
consoleFontSizeField = new JComboBox<>(FONT_SIZES);
consoleFontSizeField.setSelectedItem(Preferences.getInteger("console.font.size"));
// Sizing is screwed up on macOS, bug has been open since 2017
// https://github.com/processing/processing4/issues/232
// https://bugs.openjdk.java.net/browse/JDK-8179076
fontSizeField.setEditable(true);
consoleFontSizeField.setEditable(true);
// Interface scale: [ 100% ] (requires restart of Processing)
@@ -507,23 +513,16 @@ public class PreferencesFrame {
frame.pack();
frame.setLocationRelativeTo(null);
// Workaround for OS X, which breaks the layout when these are set earlier
// https://github.com/processing/processing/issues/3212
fontSizeField.setEditable(true);
consoleFontSizeField.setEditable(true);
// handle window closing commands for ctrl/cmd-W or hitting ESC.
pain.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
//System.out.println(e);
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
(KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
disposeFrame();
}
public void keyPressed(KeyEvent e) {
KeyStroke wc = Toolkit.WINDOW_CLOSE_KEYSTROKE;
if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
(KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
disposeFrame();
}
});
}
});
}
+3 -3
View File
@@ -536,7 +536,7 @@ public class Toolkit {
static public ImageIcon getLibIcon(String filename) {
File file = Platform.getContentFile("lib/" + filename);
if (file == null || !file.exists()) {
Messages.loge("does not exist: " + file);
Messages.err("does not exist: " + file);
return null;
}
return new ImageIcon(file.getAbsolutePath());
@@ -1032,7 +1032,7 @@ public class Toolkit {
sansBoldFont = new Font("Monospaced", Font.BOLD, size);
}
} catch (Exception e) {
Messages.loge("Could not load mono font", e);
Messages.err("Could not load mono font", e);
monoFont = new Font("Monospaced", Font.PLAIN, size);
monoBoldFont = new Font("Monospaced", Font.BOLD, size);
}
@@ -1080,7 +1080,7 @@ public class Toolkit {
sansBoldFont = new Font("SansSerif", Font.BOLD, size);
}
} catch (Exception e) {
Messages.loge("Could not load sans font", e);
Messages.err("Could not load sans font", e);
sansFont = new Font("SansSerif", Font.PLAIN, size);
sansBoldFont = new Font("SansSerif", Font.BOLD, size);
}
+1 -1
View File
@@ -95,7 +95,7 @@ class ASTViewer {
void buildAndUpdateTree(PreprocSketch ps) {
CompilationUnit cu = ps.compilationUnit;
if (cu.types().isEmpty()){
Messages.loge("No Type found in CU");
Messages.err("No Type found in CU");
return;
}
@@ -1750,7 +1750,7 @@ public class CompletionGenerator {
ASTNode testnode = parser.createAST(null);
//Base.loge("PREDICTION PARSER PROBLEMS: " + parser);
// Find closest ASTNode of the document to this word
Messages.loge("Typed: " + phrase + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
Messages.err("Typed: " + phrase + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
if(testnode instanceof MethodInvocation){
MethodInvocation mi = (MethodInvocation)testnode;
log(mi.getName() + "," + mi.getExpression() + "," + mi.typeArguments().size());
@@ -1762,7 +1762,7 @@ public class CompletionGenerator {
// Make sure nearestNode is not NULL if couldn't find a closest node
nearestNode = astRootNode;
}
Messages.loge(lineNumber + " Nearest ASTNode to PRED "
Messages.err(lineNumber + " Nearest ASTNode to PRED "
+ getNodeAsString(nearestNode));
candidates = new ArrayList<>();
@@ -1770,7 +1770,7 @@ public class CompletionGenerator {
// Determine the expression typed
if (testnode instanceof SimpleName && !noCompare) {
Messages.loge("One word expression " + getNodeAsString(testnode));
Messages.err("One word expression " + getNodeAsString(testnode));
//==> Simple one word exprssion - so is just an identifier
// Bottom up traversal of the AST to look for possible definitions at
@@ -1850,7 +1850,7 @@ public class CompletionGenerator {
} else {
// ==> Complex expression of type blah.blah2().doIt,etc
// Have to resolve it by carefully traversing AST of testNode
Messages.loge("Complex expression " + getNodeAsString(testnode));
Messages.err("Complex expression " + getNodeAsString(testnode));
log("candidates empty");
ASTNode childExpr = getChildExpression(testnode);
log("Parent expression : " + getParentExpression(testnode));
@@ -96,7 +96,6 @@ public class CompletionPanel {
* @param subWord - Partial word which triggered the code completion and which needs to be completed
* @param items - completion candidates
* @param location - Point location where popup list is to be displayed
* @param dedit
*/
public CompletionPanel(final JEditTextArea textarea,
int position, String subWord,
@@ -377,7 +376,7 @@ public class CompletionPanel {
}
}
Messages.loge(subWord + " <= subword, Inserting suggestion=> " +
Messages.err(subWord + " <= subword, Inserting suggestion=> " +
selectedSuggestion + " Current sub: " + currentSubword);
if (currentSubword.length() > 0) {
textarea.getDocument().remove(insertionPosition - currentSubwordLen,
@@ -27,7 +27,6 @@ import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -1326,7 +1325,7 @@ public class JavaEditor extends Editor {
// this method gets called twice when saving sketch for the first time
// once with new name and another with old(causing NPE). Keep an eye out
// for potential issues. See #2675. TODO:
Messages.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
Messages.err("Illegal tab name to addBreakpointComments() " + tabFilename);
return;
}
List<LineBreakpoint> bps = debugger.getBreakpoints(tab.getFileName());
@@ -1349,7 +1348,7 @@ public class JavaEditor extends Editor {
tab.setProgram(code);
tab.save();
} catch (IOException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
}
@@ -335,7 +335,7 @@ public class JavaTextArea extends PdeTextArea {
}
});
} catch (Exception e) {
Messages.loge("error while preparing suggestions", e);
Messages.err("error while preparing suggestions", e);
}
});
}
@@ -53,8 +53,6 @@ import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FileASTRequestor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
import processing.app.Messages;
import processing.app.Sketch;
@@ -154,7 +152,7 @@ public class PreprocService {
}
}
} catch (Exception e) {
Messages.loge("problem in preprocessor service loop", e);
Messages.err("problem in preprocessor service loop", e);
}
}
Messages.log("PPS: Bye!");
@@ -224,7 +222,7 @@ public class PreprocService {
.thenAcceptBothAsync(lastCallback, (ps, a) -> callback.accept(ps))
// Make sure exception in callback won't cancel whole callback chain
.handleAsync((res, e) -> {
if (e != null) Messages.loge("PPS: exception in callback", e);
if (e != null) Messages.err("PPS: exception in callback", e);
return res;
});
return lastCallback;
@@ -314,7 +312,7 @@ public class PreprocService {
try {
listener.accept(ps);
} catch (Exception e) {
Messages.loge("error when firing preprocessing listener", e);
Messages.err("error when firing preprocessing listener", e);
}
}
}
@@ -734,7 +732,7 @@ public class PreprocService {
* for the sketch's combined PDE code (not ".java" tabs).
* </p>
*/
private class ProcessingASTRequester extends FileASTRequestor {
static private class ProcessingASTRequester extends FileASTRequestor {
private final String mainSource;
private final List<IProblem> problems;
private CompilationUnit mainCompilationUnit;
@@ -257,21 +257,21 @@ public class RuntimePathBuilder {
}
/**
* Invalidate all of the runtime path caches associated with sketch libraries.
* Invalidate all the runtime path caches associated with sketch libraries.
*/
public void markLibrariesChanged() {
invalidateAll(libraryDependentCaches);
}
/**
* Invalidate all of the runtime path caches associated with sketch library imports.
* Invalidate all the runtime path caches associated with sketch library imports.
*/
public void markLibraryImportsChanged() {
invalidateAll(libraryImportsDependentCaches);
}
/**
* Invalidate all of the runtime path caches associated with the code folder having changed.
* Invalidate all the runtime path caches associated with the code folder having changed.
*/
public void markCodeFolderChanged() {
invalidateAll(codeFolderDependentCaches);
@@ -324,7 +324,7 @@ public class RuntimePathBuilder {
try {
return Paths.get(path).toUri().toURL();
} catch (MalformedURLException e) {
Messages.loge("malformed URL when preparing sketch classloader", e);
Messages.err("malformed URL when preparing sketch classloader", e);
return null;
}
})
@@ -556,9 +556,7 @@ public class RuntimePathBuilder {
/**
* Determine if a package is ignorable because it is standard.
*
* Determine if a package is ignorable on the sketch path because it is standard. This is
* different than being ignorable in imports recommendations.
* This is different from being ignorable in imports recommendations.
*
* @param packageName The name of the package to evaluate.
* @return True if the package is part of standard Java (like java.lang.*). False otherwise.
@@ -570,8 +568,8 @@ public class RuntimePathBuilder {
/**
* Find a fully qualified jar name.
*
* @param jarName The jar name like "javafx.base.jar" for which a fully qualified entry should be
* created.
* @param jarName The jar name like "javafx.base.jar" for which a
* fully qualified entry should be created.
* @return The fully qualified classpath entry like ".../Processing.app/Contents/PlugIns/
* adoptopenjdk-11.0.1.jdk/Contents/Home/lib/javafx.base.jar"
*/
@@ -53,7 +53,7 @@ public class ArrayFieldNode extends VariableNode {
try {
array.setValue(index, value);
} catch (InvalidTypeException | ClassNotLoadedException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
this.value = value;
}
@@ -1547,15 +1547,15 @@ public class Debugger {
private void loge(String msg, Throwable t) {
if (t != null) {
Messages.loge(getClass().getName() + " " + msg, t);
Messages.err(getClass().getName() + " " + msg, t);
} else {
Messages.loge(getClass().getName() + " " + msg);
Messages.err(getClass().getName() + " " + msg);
}
}
static private void logitse(Throwable t) {
Messages.loge("incompatible thread state?", t);
Messages.err("incompatible thread state?", t);
}
@@ -1607,7 +1607,7 @@ public class Debugger {
} catch (VMDisconnectedException e) {
Messages.log("VMEventReader quit on VM disconnect");
} catch (Exception e) {
Messages.loge("VMEventReader quit", e);
Messages.err("VMEventReader quit", e);
}
}
}
@@ -56,9 +56,9 @@ public class FieldNode extends VariableNode {
try {
obj.setValue(field, value);
} catch (InvalidTypeException ite) {
Messages.loge(null, ite);
Messages.err(null, ite);
} catch (ClassNotLoadedException cnle) {
Messages.loge(null, cnle);
Messages.err(null, cnle);
}
this.value = value;
}
@@ -34,7 +34,7 @@ import com.sun.jdi.request.BreakpointRequest;
/**
* Model/Controller of a line breakpoint. Can be set before or while debugging.
* Adds a highlight using the debuggers view ({@link DebugEditor}).
* Adds a highlight using the debuggers view.
*/
public class LineBreakpoint implements ClassLoadListener {
protected Debugger dbg; // the debugger
@@ -131,7 +131,7 @@ public class LineBreakpoint implements ClassLoadListener {
log("attached breakpoint to " + line + " -> " + javaLine);
return true;
} catch (AbsentInformationException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
return false;
}
@@ -158,7 +158,7 @@ public class LineBreakpoint implements ClassLoadListener {
/**
* Set this breakpoint. Adds the line highlight. If Debugger is paused
* also attaches the breakpoint by calling {@link #attach()}.
* also attaches the breakpoint by calling {@link #attach}.
*/
protected void set() {
dbg.addClassLoadListener(this); // class may not yet be loaded
@@ -37,8 +37,8 @@ import processing.app.Messages;
/**
* Describes an ID for a code line. Comprised of a file name and a (0-based)
* line number. Can track changes to the line number due to text editing by
* attaching a {@link Document}. Registered {@link LineListener}s are notified
* of changes to the line number.
* attaching a {@link Document}. Registered listeners are notified of changes
* to the line number.
*/
public class LineID implements DocumentListener {
protected String fileName; // the filename
@@ -151,7 +151,7 @@ public class LineID implements DocumentListener {
this.doc = doc;
doc.addDocumentListener(this);
} catch (BadLocationException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
pos = null;
this.doc = null;
}
@@ -52,7 +52,7 @@ public class LocalVariableNode extends VariableNode {
try {
frame.setValue(var, value);
} catch (InvalidTypeException | ClassNotLoadedException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
this.value = value;
}
@@ -288,11 +288,11 @@ public class Runner implements MessageConsumer {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
Messages.loge(getClass().getName() + " interrupted", ie);
Messages.err(getClass().getName() + " interrupted", ie);
// ie.printStackTrace(sketchErr);
}
} catch (IOException e) {
Messages.loge(getClass().getName() + " while attaching to VM", e);
Messages.err(getClass().getName() + " while attaching to VM", e);
}
}
// } catch (IOException exc) {
+15 -7
View File
@@ -10,6 +10,13 @@ o but pdex.completion.trigger=true does
X https://github.com/processing/processing/issues/5691
X remove code for pulling fonts from JAVA_HOME/lib/fonts
X no longer exists in Java 11
o exporting on Linux is setting the wrong path? or an extra subfolder is used?
X https://github.com/processing/processing/issues/6182
X checked, seems to be working
o fix height of font size dropdown in prefs (why one pixel off?)
X file prefs combo box issue
o https://github.com/processing/processing4/issues/232
X change Messages.loge() to Messages.err()
Sam updates
X can we get rid of pdexEnabled? does the current code work w/ java tabs?
@@ -17,16 +24,16 @@ X https://github.com/processing/processing4/issues/157
X https://github.com/processing/processing4/pull/230
_ change Messages.loge() to Messages.err()
_ dealing with reference.zip
_ psk files, doing that for examples
_ Toolkit.getSansFont() will use the internal ProcessingSansPro font
_ which means it gets used inside ManagerFrame, and prevents the theme from updating the font
_ auto-complete not triggering, workaround as pref?
_ Auto-completion: [ ] Disabled [ ] Show on Ctrl-Space [ ] Always show
_ https://github.com/processing/processing/issues/5691
_ IDE cursor position is wrong if font size is changed in preferences on macOS
_ probably related to second displays, need to hook one up and test
_ https://github.com/processing/processing4/issues/194
_ replace bug numbers
@@ -35,7 +42,11 @@ _ with http://processing.org/bugs/bugzilla/1188.html
_ also code.google.com URLs with Github URLs (numbers are sorta in sync)
ui is ugly on macOS
_ fix height of font size dropdown in prefs (why one pixel off?)
_ sort out ui.font plus the other fonts inside theme.txt
_ Toolkit.getSansFont() will use the internal ProcessingSansPro font
_ which means it gets used inside ManagerFrame, and prevents the theme from updating the font
_ while that font could exist in theme.txt, getSansFont() also handles the language fallback version
_ which perhaps, that pref should come from the translations: i.e. some sort of override setting
_ better default fonts for Swing; argh
_ file an issue with the images
_ https://www.pushing-pixels.org/2017/01/17/using-san-francisco-font-in-swing-applications-on-a-mac.html
@@ -64,9 +75,6 @@ _ when exporting an app, run xattr on it to handle "app is damaged" errors?
_ https://osxdaily.com/2019/02/13/fix-app-damaged-cant-be-opened-trash-error-mac/
_ https://github.com/processing/processing/issues/4214
_ exporting on Linux is setting the wrong path? or an extra subfolder is used?
_ https://github.com/processing/processing/issues/6182
_ when lib downloads (batik) go dead, fallback to the download.processing.org version
_ or for now, tell users how to do it manually