From f493e0468796010d804cf728e1a268733b7e4822 Mon Sep 17 00:00:00 2001 From: Jonathan Feinberg Date: Wed, 2 Apr 2014 16:09:04 -0400 Subject: [PATCH] Permit Mode developers to run their Modes in Eclipse (or however they like) during development. --- app/src/processing/app/Base.java | 4 ++-- app/src/processing/app/contrib/ModeContribution.java | 12 +++++++++++- core/src/processing/core/PApplet.java | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 322392e98..827a45ee4 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -364,13 +364,13 @@ public class Base { } else { for (Mode m : getModeList()) { if (m.getIdentifier().equals(lastModeIdentifier)) { - logf("Setting next mode to {0}.", lastModeIdentifier); //$NON-NLS-1$ + logf("Setting next mode to %s.", lastModeIdentifier); //$NON-NLS-1$ nextMode = m; } } if (nextMode == null) { nextMode = coreModes[0]; - logf("Could not find mode {0}, using default.", lastModeIdentifier); //$NON-NLS-1$ + logf("Could not find mode %s, using default.", lastModeIdentifier); //$NON-NLS-1$ } } diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index 9fdac9f0d..27e363484 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -24,7 +24,6 @@ package processing.app.contrib; import java.io.File; import java.lang.reflect.Constructor; import java.util.*; -import java.util.HashMap; import processing.app.Base; import processing.app.Mode; @@ -110,6 +109,17 @@ public class ModeContribution extends LocalContribution { } } } + + // This allows you to build and test your Mode code from Eclipse. + // -Dusemode=com.foo.FrobMode:/path/to/FrobMode/resources + final String usemode = System.getProperty("usemode"); + if (usemode != null) { + final String[] modeinfo = usemode.split(":"); + final String modeClass = modeinfo[0]; + final String modeResourcePath = modeinfo[1]; + System.err.println("Attempting to load " + modeClass + " with resources at " + modeResourcePath); + contribModes.add(ModeContribution.load(base, new File(modeResourcePath), modeClass)); + } } diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 18075f106..4810a7476 100755 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -784,6 +784,8 @@ public class PApplet extends Applet */ static public final String ARGS_EDITOR_LOCATION = "--editor-location"; + static public final String ARGS_EXTERNAL = "--external"; + /** * Location for where to position the applet window on screen. *

@@ -791,8 +793,6 @@ public class PApplet extends Applet * location, or could be used by other classes to launch at a * specific position on-screen. */ - static public final String ARGS_EXTERNAL = "--external"; - static public final String ARGS_LOCATION = "--location"; static public final String ARGS_DISPLAY = "--display";