From 3a032ac3705b94eda49bc94afb3a6c0c55437e0b Mon Sep 17 00:00:00 2001 From: Jonathan Feinberg Date: Mon, 14 Apr 2014 15:52:05 -0400 Subject: [PATCH 1/3] Allow user to suppress JVM warning if they know what they're doing. --- .../app/platform/LinuxPlatform.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/processing/app/platform/LinuxPlatform.java b/app/src/processing/app/platform/LinuxPlatform.java index 8e9ee7c71..d1dc0451f 100644 --- a/app/src/processing/app/platform/LinuxPlatform.java +++ b/app/src/processing/app/platform/LinuxPlatform.java @@ -31,21 +31,26 @@ import processing.app.Preferences; public class LinuxPlatform extends Platform { + private static final boolean SUPPRESS_JVM_WARNING = + Boolean.parseBoolean(System.getProperty("SUPPRESS_JVM_WARNING", "false")); + public void init(Base base) { super.init(base); - String javaVendor = System.getProperty("java.vendor"); - String javaVM = System.getProperty("java.vm.name"); - if (javaVendor == null || - (!javaVendor.contains("Sun") && !javaVendor.contains("Oracle")) || - javaVM == null || !javaVM.contains("Java")) { - Base.showWarning("Not fond of this Java VM", - "Processing requires Java 6 from Sun (i.e. the sun-java-jdk\n" + - "package on Ubuntu). Other versions such as OpenJDK, IcedTea,\n" + - "and GCJ are strongly discouraged. Among other things, you're\n" + - "likely to run into problems with sketch window size and\n" + - "placement. For more background, please read the wiki:\n" + - "http://wiki.processing.org/w/Supported_Platforms#Linux", null); + if (!SUPPRESS_JVM_WARNING) { + final String javaVendor = System.getProperty("java.vendor"); + final String javaVM = System.getProperty("java.vm.name"); + if (javaVendor == null || + (!javaVendor.contains("Sun") && !javaVendor.contains("Oracle")) || + javaVM == null || !javaVM.contains("Java")) { + Base.showWarning("Not fond of this Java VM", + "Processing requires Java 6 from Sun (i.e. the sun-java-jdk\n" + + "package on Ubuntu). Other versions such as OpenJDK, IcedTea,\n" + + "and GCJ are strongly discouraged. Among other things, you're\n" + + "likely to run into problems with sketch window size and\n" + + "placement. For more background, please read the wiki:\n" + + "http://wiki.processing.org/w/Supported_Platforms#Linux", null); + } } } From 563a5f3c6bbe383480d512e3a9b2c57e69e7bbb1 Mon Sep 17 00:00:00 2001 From: Jonathan Feinberg Date: Mon, 14 Apr 2014 15:53:19 -0400 Subject: [PATCH 2/3] Permit Modes to specify different default file extension for auxilliary (not main pde) files created in new tabs. --- app/src/processing/app/Mode.java | 12 ++++++++++++ app/src/processing/app/Sketch.java | 5 +---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index dc609ae81..741474606 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -1046,6 +1046,18 @@ public abstract class Mode { abstract public String getDefaultExtension(); + /** + * Returns the appropriate file extension to use for auxilliary source files in a sketch. + * For example, in a Java-mode sketch, auxilliary files should be name "Foo.java"; in + * Python mode, they should be named "foo.py". + * + *

Modes that do not override this function will get the default behavior of returning the + * default extension. + */ + public String getModuleExtension() { + return getDefaultExtension(); + } + /** * Returns a String[] array of proper extensions. diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 198eadeec..20e96b56e 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -333,9 +333,6 @@ public class Sketch { /** * This is called upon return from entering a new file name. * (that is, from either newCode or renameCode after the prompt) - * This code is almost identical for both the newCode and renameCode - * cases, so they're kept merged except for right in the middle - * where they diverge. */ protected void nameCode(String newName) { newName = newName.trim(); @@ -348,7 +345,7 @@ public class Sketch { // Add the extension here, this simplifies some of the logic below. if (newName.indexOf('.') == -1) { - newName += "." + mode.getDefaultExtension(); + newName += "." + (renamingCode ? mode.getDefaultExtension() : mode.getModuleExtension()); } // if renaming to the same thing as before, just ignore. From 9b14288d48bb4c56ea647826d1c4f5f1233f1ad7 Mon Sep 17 00:00:00 2001 From: Jonathan Feinberg Date: Mon, 14 Apr 2014 17:56:44 -0400 Subject: [PATCH 3/3] Roll back ability to silence JVM warning. --- .../app/platform/LinuxPlatform.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/app/src/processing/app/platform/LinuxPlatform.java b/app/src/processing/app/platform/LinuxPlatform.java index d1dc0451f..8e9ee7c71 100644 --- a/app/src/processing/app/platform/LinuxPlatform.java +++ b/app/src/processing/app/platform/LinuxPlatform.java @@ -31,26 +31,21 @@ import processing.app.Preferences; public class LinuxPlatform extends Platform { - private static final boolean SUPPRESS_JVM_WARNING = - Boolean.parseBoolean(System.getProperty("SUPPRESS_JVM_WARNING", "false")); - public void init(Base base) { super.init(base); - if (!SUPPRESS_JVM_WARNING) { - final String javaVendor = System.getProperty("java.vendor"); - final String javaVM = System.getProperty("java.vm.name"); - if (javaVendor == null || - (!javaVendor.contains("Sun") && !javaVendor.contains("Oracle")) || - javaVM == null || !javaVM.contains("Java")) { - Base.showWarning("Not fond of this Java VM", - "Processing requires Java 6 from Sun (i.e. the sun-java-jdk\n" + - "package on Ubuntu). Other versions such as OpenJDK, IcedTea,\n" + - "and GCJ are strongly discouraged. Among other things, you're\n" + - "likely to run into problems with sketch window size and\n" + - "placement. For more background, please read the wiki:\n" + - "http://wiki.processing.org/w/Supported_Platforms#Linux", null); - } + String javaVendor = System.getProperty("java.vendor"); + String javaVM = System.getProperty("java.vm.name"); + if (javaVendor == null || + (!javaVendor.contains("Sun") && !javaVendor.contains("Oracle")) || + javaVM == null || !javaVM.contains("Java")) { + Base.showWarning("Not fond of this Java VM", + "Processing requires Java 6 from Sun (i.e. the sun-java-jdk\n" + + "package on Ubuntu). Other versions such as OpenJDK, IcedTea,\n" + + "and GCJ are strongly discouraged. Among other things, you're\n" + + "likely to run into problems with sketch window size and\n" + + "placement. For more background, please read the wiki:\n" + + "http://wiki.processing.org/w/Supported_Platforms#Linux", null); } }