mirror of
https://github.com/processing/processing4.git
synced 2026-02-20 13:55:37 +01:00
merge command-line processing changes to Procesing v.2.1
This commit is contained in:
@@ -48,6 +48,7 @@ public class Commander implements RunnerListener {
|
||||
static final String forceArg = "--force";
|
||||
static final String outputArg = "--output=";
|
||||
static final String exportApplicationArg = "--export";
|
||||
static final String noJavaArg = "--export";
|
||||
static final String platformArg = "--platform=";
|
||||
static final String bitsArg = "--bits=";
|
||||
// static final String preferencesArg = "--preferences=";
|
||||
@@ -66,26 +67,7 @@ public class Commander implements RunnerListener {
|
||||
PrintStream systemErr;
|
||||
|
||||
|
||||
static public void main(String[] args) {
|
||||
/*
|
||||
if (args == null || args.length == 0) {
|
||||
// System.out.println(System.getProperty("user.dir"));
|
||||
args = new String[] {
|
||||
"--export",
|
||||
// "--build",
|
||||
// "--run",
|
||||
// "--present",
|
||||
"--force",
|
||||
// "--platform=windows",
|
||||
"--platform=macosx",
|
||||
"--bits=64",
|
||||
"--sketch=/Users/fry/coconut/processing/java/examples/Basics/Lights/Directional",
|
||||
// "--sketch=/Users/fry/coconut/sketchbook/sketchbook_libraries_test",
|
||||
"--output=/Users/fry/Desktop/test-build"
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
static public void main(String[] args) {
|
||||
// Do this early so that error messages go to the console
|
||||
Base.setCommandLine();
|
||||
// init the platform so that prefs and other native code is ready to go
|
||||
@@ -108,8 +90,10 @@ public class Commander implements RunnerListener {
|
||||
boolean force = false; // replace that no good output folder
|
||||
// String preferencesPath = null;
|
||||
int platform = PApplet.platform; // default to this platform
|
||||
int platformBits = 0;
|
||||
// int platformBits = 0;
|
||||
int platformBits = Base.getNativeBits();
|
||||
int task = HELP;
|
||||
boolean embedJava = true;
|
||||
|
||||
// Turns out the output goes as MacRoman or something else useless.
|
||||
// http://code.google.com/p/processing/issues/detail?id=1418
|
||||
@@ -122,6 +106,9 @@ public class Commander implements RunnerListener {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// File preferencesFile = Base.getSettingsFile("preferences.txt");
|
||||
// System.out.println("Preferences file at " + preferencesFile.getAbsolutePath());
|
||||
|
||||
for (String arg : args) {
|
||||
if (arg.length() == 0) {
|
||||
// ignore it, just the crappy shell script
|
||||
@@ -146,24 +133,29 @@ public class Commander implements RunnerListener {
|
||||
|
||||
} else if (arg.equals(exportApplicationArg)) {
|
||||
task = EXPORT;
|
||||
|
||||
} else if (arg.equals(noJavaArg)) {
|
||||
embedJava = false;
|
||||
|
||||
} else if (arg.startsWith(platformArg)) {
|
||||
String platformStr = arg.substring(platformArg.length());
|
||||
platform = Base.getPlatformIndex(platformStr);
|
||||
if (platform == -1) {
|
||||
complainAndQuit(platformStr + " should instead be " +
|
||||
"'windows', 'macosx', or 'linux'.", true);
|
||||
}
|
||||
complainAndQuit("The --platform option has been removed from Processing 2.1.", false);
|
||||
// String platformStr = arg.substring(platformArg.length());
|
||||
// platform = Base.getPlatformIndex(platformStr);
|
||||
// if (platform == -1) {
|
||||
// complainAndQuit(platformStr + " should instead be " +
|
||||
// "'windows', 'macosx', or 'linux'.", true);
|
||||
// }
|
||||
|
||||
} else if (arg.startsWith(bitsArg)) {
|
||||
String bitsStr = arg.substring(bitsArg.length());
|
||||
if (bitsStr.equals("32")) {
|
||||
platformBits = 32;
|
||||
} else if (bitsStr.equals("64")) {
|
||||
platformBits = 64;
|
||||
} else {
|
||||
complainAndQuit("Bits should be either 32 or 64, not " + bitsStr, true);
|
||||
}
|
||||
complainAndQuit("The --bits option has been removed from Processing 2.1.", false);
|
||||
// String bitsStr = arg.substring(bitsArg.length());
|
||||
// if (bitsStr.equals("32")) {
|
||||
// platformBits = 32;
|
||||
// } else if (bitsStr.equals("64")) {
|
||||
// platformBits = 64;
|
||||
// } else {
|
||||
// complainAndQuit("Bits should be either 32 or 64, not " + bitsStr, true);
|
||||
// }
|
||||
|
||||
} else if (arg.startsWith(sketchArg)) {
|
||||
sketchPath = arg.substring(sketchArg.length());
|
||||
@@ -286,11 +278,11 @@ public class Commander implements RunnerListener {
|
||||
// if (platformBits == 0) {
|
||||
// platformBits = Base.getNativeBits();
|
||||
// }
|
||||
if (platformBits == 0 &&
|
||||
Library.hasMultipleArch(platform, build.getImportedLibraries())) {
|
||||
complainAndQuit("This sketch can be exported for 32- or 64-bit, please specify one.", true);
|
||||
}
|
||||
success = build.exportApplication(outputFolder, platform, platformBits);
|
||||
// if (platformBits == 0 &&
|
||||
// Library.hasMultipleArch(platform, build.getImportedLibraries())) {
|
||||
// complainAndQuit("This sketch can be exported for 32- or 64-bit, please specify one.", true);
|
||||
// }
|
||||
success = build.exportApplication(outputFolder, platform, platformBits, embedJava);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,6 +294,7 @@ public class Commander implements RunnerListener {
|
||||
|
||||
} catch (SketchException re) {
|
||||
statusError(re);
|
||||
System.exit(1);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -329,13 +322,16 @@ public class Commander implements RunnerListener {
|
||||
if (codeIndex != -1) {
|
||||
// format the runner exception like emacs
|
||||
//blah.java:2:10:2:13: Syntax Error: This is a big error message
|
||||
// Emacs doesn't like the double line thing coming from Java
|
||||
// https://github.com/processing/processing/issues/2158
|
||||
String filename = sketch.getCode(codeIndex).getFileName();
|
||||
int line = re.getCodeLine() + 1;
|
||||
int column = re.getCodeColumn() + 1;
|
||||
//if (column == -1) column = 0;
|
||||
// TODO if column not specified, should just select the whole line.
|
||||
// But what's the correct syntax for that?
|
||||
systemErr.println(filename + ":" +
|
||||
line + ":" + column + ":" +
|
||||
line + ":" + column + ":" +
|
||||
line + ":" + column + ":" + " " + re.getMessage());
|
||||
|
||||
} else { // no line number, pass the trace along to the user
|
||||
@@ -376,11 +372,12 @@ public class Commander implements RunnerListener {
|
||||
out.println("--present Preprocess, compile, and run a sketch full screen.");
|
||||
out.println();
|
||||
out.println("--export Export an application.");
|
||||
out.println("--platform Specify the platform (export to application only).");
|
||||
out.println(" Should be one of 'windows', 'macosx', or 'linux'.");
|
||||
out.println("--bits Must be specified if libraries are used that are");
|
||||
out.println(" 32- or 64-bit specific such as the OpenGL library.");
|
||||
out.println(" Otherwise specify 0 or leave it out.");
|
||||
out.println("--no-java Do not embed Java. Use at your own risk!");
|
||||
// out.println("--platform Specify the platform (export to application only).");
|
||||
// out.println(" Should be one of 'windows', 'macosx', or 'linux'.");
|
||||
// out.println("--bits Must be specified if libraries are used that are");
|
||||
// out.println(" 32- or 64-bit specific such as the OpenGL library.");
|
||||
// out.println(" Otherwise specify 0 or leave it out.");
|
||||
out.println();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Compiler {
|
||||
// System.arraycopy(sourceFiles, 0, command, baseCommand.length, sourceCount);
|
||||
String[] command = PApplet.concat(baseCommand, sourceFiles);
|
||||
|
||||
//PApplet.println(command);
|
||||
// PApplet.println(command);
|
||||
|
||||
try {
|
||||
// Load errors into a local StringBuffer
|
||||
|
||||
@@ -454,6 +454,12 @@ public class JavaBuild {
|
||||
javaClassPath = javaClassPath.substring(1, javaClassPath.length() - 1);
|
||||
}
|
||||
classPath += File.pathSeparator + javaClassPath;
|
||||
|
||||
// But make sure that there isn't anything in there that's missing,
|
||||
// otherwise ECJ will complain and die. For instance, Java 1.7 (or maybe
|
||||
// it's appbundler?) adds Java/Classes to the path, which kills us.
|
||||
//String[] classPieces = PApplet.split(classPath, File.pathSeparator);
|
||||
// Nah, nevermind... we'll just create the @!#$! folder until they fix it.
|
||||
|
||||
|
||||
// 3. then loop over the code[] and save each .java file
|
||||
@@ -1084,6 +1090,7 @@ public class JavaBuild {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
File folder = null;
|
||||
for (String platformName : PConstants.platformNames) {
|
||||
int platform = Base.getPlatformIndex(platformName);
|
||||
@@ -1107,23 +1114,42 @@ public class JavaBuild {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
File folder = null;
|
||||
String platformName = Base.getPlatformName();
|
||||
boolean embedJava = Preferences.getBoolean("export.application.embed_java");
|
||||
if (Library.hasMultipleArch(PApplet.platform, importedLibraries)) {
|
||||
if (Base.getNativeBits() == 32) {
|
||||
// export the 32-bit version
|
||||
folder = new File(sketch.getFolder(), "application." + platformName + "32");
|
||||
if (!exportApplication(folder, PApplet.platform, 32, embedJava)) {
|
||||
return false;
|
||||
}
|
||||
} else if (Base.getNativeBits() == 64) {
|
||||
// export the 64-bit version
|
||||
folder = new File(sketch.getFolder(), "application." + platformName + "64");
|
||||
if (!exportApplication(folder, PApplet.platform, 64, embedJava)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else { // just make a single one for this platform
|
||||
folder = new File(sketch.getFolder(), "application." + platformName);
|
||||
if (!exportApplication(folder, PApplet.platform, 0, embedJava)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true; // all good
|
||||
}
|
||||
|
||||
|
||||
// public boolean exportApplication(String destPath,
|
||||
// String platformName,
|
||||
// int exportBits) throws IOException, RunnerException {
|
||||
// return exportApplication(destPath, Base.getPlatformIndex(platformName), exportBits);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Export to application without GUI. Also called by the Commander.
|
||||
*/
|
||||
protected boolean exportApplication(File destFolder,
|
||||
int exportPlatform,
|
||||
int exportBits) throws IOException, SketchException {
|
||||
int exportBits,
|
||||
boolean embedJava) throws IOException, SketchException {
|
||||
// TODO this should probably be a dialog box instead of a warning
|
||||
// on the terminal. And the message should be written better than this.
|
||||
// http://code.google.com/p/processing/issues/detail?id=884
|
||||
@@ -1154,13 +1180,54 @@ public class JavaBuild {
|
||||
/// on macosx, need to copy .app skeleton since that's
|
||||
/// also where the jar files will be placed
|
||||
File dotAppFolder = null;
|
||||
// String jdkFolderName = null;
|
||||
String jvmRuntime = "";
|
||||
if (exportPlatform == PConstants.MACOSX) {
|
||||
dotAppFolder = new File(destFolder, sketch.getName() + ".app");
|
||||
// String APP_SKELETON = "skeleton.app";
|
||||
//File dotAppSkeleton = new File(folder, APP_SKELETON);
|
||||
File dotAppSkeleton = mode.getContentFile("application/template.app");
|
||||
Base.copyDir(dotAppSkeleton, dotAppFolder);
|
||||
|
||||
File contentsOrig = new File(Base.getJavaHome(), "../../../../..");
|
||||
|
||||
if (embedJava) {
|
||||
File jdkFolder = new File(Base.getJavaHome(), "../../..");
|
||||
String jdkFolderName = jdkFolder.getCanonicalFile().getName();
|
||||
jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>";
|
||||
}
|
||||
|
||||
// File dotAppSkeleton = mode.getContentFile("application/template.app");
|
||||
// Base.copyDir(dotAppSkeleton, dotAppFolder);
|
||||
File contentsFolder = new File(dotAppFolder, "Contents");
|
||||
contentsFolder.mkdirs();
|
||||
|
||||
// Info.plist will be written later
|
||||
|
||||
// set the jar folder to a different location than windows/linux
|
||||
//jarFolder = new File(dotAppFolder, "Contents/Resources/Java");
|
||||
jarFolder = new File(contentsFolder, "Java");
|
||||
|
||||
File macosFolder = new File(contentsFolder, "MacOS");
|
||||
macosFolder.mkdirs();
|
||||
Base.copyFile(new File(contentsOrig, "MacOS/Processing"),
|
||||
new File(contentsFolder, "MacOS/" + sketch.getName()));
|
||||
|
||||
File pkgInfo = new File(contentsFolder, "PkgInfo");
|
||||
PrintWriter writer = PApplet.createWriter(pkgInfo);
|
||||
writer.println("APPL????");
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
// Use faster(?) native copy here (also to do sym links)
|
||||
if (embedJava) {
|
||||
Base.copyDirNative(new File(contentsOrig, "PlugIns"),
|
||||
new File(contentsFolder, "PlugIns"));
|
||||
}
|
||||
|
||||
File resourcesFolder = new File(contentsFolder, "Resources");
|
||||
Base.copyDir(new File(contentsOrig, "Resources/en.lproj"),
|
||||
new File(resourcesFolder, "en.lproj"));
|
||||
Base.copyFile(mode.getContentFile("application/sketch.icns"),
|
||||
new File(resourcesFolder, "sketch.icns"));
|
||||
|
||||
/*
|
||||
String stubName = "Contents/MacOS/JavaApplicationStub";
|
||||
// need to set the stub to executable
|
||||
// will work on osx or *nix, but just dies on windows, oh well..
|
||||
@@ -1183,13 +1250,20 @@ public class JavaBuild {
|
||||
String stubPath = stubFile.getAbsolutePath();
|
||||
Runtime.getRuntime().exec(new String[] { "chmod", "+x", stubPath });
|
||||
}
|
||||
|
||||
// set the jar folder to a different location than windows/linux
|
||||
jarFolder = new File(dotAppFolder, "Contents/Resources/Java");
|
||||
*/
|
||||
} else if (exportPlatform == PConstants.LINUX) {
|
||||
if (embedJava) {
|
||||
Base.copyDirNative(Base.getJavaHome(), new File(destFolder, "java"));
|
||||
}
|
||||
|
||||
} else if (exportPlatform == PConstants.WINDOWS) {
|
||||
if (embedJava) {
|
||||
Base.copyDir(Base.getJavaHome(), new File(destFolder, "java"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// make the jar folder (windows and linux)
|
||||
/// make the jar folder (all platforms)
|
||||
|
||||
if (!jarFolder.exists()) jarFolder.mkdirs();
|
||||
|
||||
@@ -1374,13 +1448,22 @@ public class JavaBuild {
|
||||
|
||||
/// figure out run options for the VM
|
||||
|
||||
String runOptions = Preferences.get("run.options");
|
||||
// this is too vague. if anyone is using it, we can bring it back
|
||||
// String runOptions = Preferences.get("run.options");
|
||||
List<String> runOptions = new ArrayList<String>();
|
||||
if (Preferences.getBoolean("run.options.memory")) {
|
||||
runOptions += " -Xms" +
|
||||
Preferences.get("run.options.memory.initial") + "m";
|
||||
runOptions += " -Xmx" +
|
||||
Preferences.get("run.options.memory.maximum") + "m";
|
||||
runOptions.add("-Xms" + Preferences.get("run.options.memory.initial") + "m");
|
||||
runOptions.add("-Xmx" + Preferences.get("run.options.memory.maximum") + "m");
|
||||
}
|
||||
|
||||
StringBuilder jvmOptionsList = new StringBuilder();
|
||||
for (String opt : runOptions) {
|
||||
jvmOptionsList.append(" <string>");
|
||||
jvmOptionsList.append(opt);
|
||||
jvmOptionsList.append("</string>");
|
||||
jvmOptionsList.append('\n');
|
||||
}
|
||||
|
||||
// if (exportPlatform == PConstants.MACOSX) {
|
||||
// // If no bits specified (libs are all universal, or no native libs)
|
||||
// // then exportBits will be 0, and can be controlled via "Get Info".
|
||||
@@ -1395,10 +1478,12 @@ public class JavaBuild {
|
||||
/// macosx: write out Info.plist (template for classpath, etc)
|
||||
|
||||
if (exportPlatform == PConstants.MACOSX) {
|
||||
String PLIST_TEMPLATE = "template.plist";
|
||||
//String PLIST_TEMPLATE = "template.plist";
|
||||
String PLIST_TEMPLATE = "Info.plist.tmpl";
|
||||
File plistTemplate = new File(sketch.getFolder(), PLIST_TEMPLATE);
|
||||
if (!plistTemplate.exists()) {
|
||||
plistTemplate = mode.getContentFile("application/template.plist");
|
||||
//plistTemplate = mode.getContentFile("application/template.plist");
|
||||
plistTemplate = mode.getContentFile("application/Info.plist.tmpl");
|
||||
}
|
||||
File plistFile = new File(dotAppFolder, "Contents/Info.plist");
|
||||
PrintWriter pw = PApplet.createWriter(plistFile);
|
||||
@@ -1408,33 +1493,37 @@ public class JavaBuild {
|
||||
if (lines[i].indexOf("@@") != -1) {
|
||||
StringBuffer sb = new StringBuffer(lines[i]);
|
||||
int index = 0;
|
||||
while ((index = sb.indexOf("@@vmoptions@@")) != -1) {
|
||||
sb.replace(index, index + "@@vmoptions@@".length(),
|
||||
runOptions);
|
||||
while ((index = sb.indexOf("@@jvm_runtime@@")) != -1) {
|
||||
sb.replace(index, index + "@@jvm_runtime@@".length(),
|
||||
jvmRuntime);
|
||||
}
|
||||
while ((index = sb.indexOf("@@jvm_options_list@@")) != -1) {
|
||||
sb.replace(index, index + "@@jvm_options_list@@".length(),
|
||||
jvmOptionsList.toString());
|
||||
}
|
||||
while ((index = sb.indexOf("@@sketch@@")) != -1) {
|
||||
sb.replace(index, index + "@@sketch@@".length(),
|
||||
sketch.getName());
|
||||
}
|
||||
while ((index = sb.indexOf("@@classpath@@")) != -1) {
|
||||
sb.replace(index, index + "@@classpath@@".length(),
|
||||
exportClassPath.toString());
|
||||
}
|
||||
// while ((index = sb.indexOf("@@classpath@@")) != -1) {
|
||||
// sb.replace(index, index + "@@classpath@@".length(),
|
||||
// exportClassPath.toString());
|
||||
// }
|
||||
while ((index = sb.indexOf("@@lsuipresentationmode@@")) != -1) {
|
||||
sb.replace(index, index + "@@lsuipresentationmode@@".length(),
|
||||
Preferences.getBoolean("export.application.fullscreen") ? "4" : "0");
|
||||
}
|
||||
while ((index = sb.indexOf("@@lsarchitecturepriority@@")) != -1) {
|
||||
// More about this mess: http://support.apple.com/kb/TS2827
|
||||
// First default to exportBits == 0 case
|
||||
String arch = "<string>x86_64</string>\n <string>i386</string>";
|
||||
if (exportBits == 32) {
|
||||
arch = "<string>i386</string>";
|
||||
} else if (exportBits == 64) {
|
||||
arch = "<string>x86_64</string>";
|
||||
}
|
||||
sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch);
|
||||
}
|
||||
// while ((index = sb.indexOf("@@lsarchitecturepriority@@")) != -1) {
|
||||
// // More about this mess: http://support.apple.com/kb/TS2827
|
||||
// // First default to exportBits == 0 case
|
||||
// String arch = "<string>x86_64</string>\n <string>i386</string>";
|
||||
// if (exportBits == 32) {
|
||||
// arch = "<string>i386</string>";
|
||||
// } else if (exportBits == 64) {
|
||||
// arch = "<string>x86_64</string>";
|
||||
// }
|
||||
// sb.replace(index, index + "@@lsarchitecturepriority@@".length(), arch);
|
||||
// }
|
||||
|
||||
lines[i] = sb.toString();
|
||||
}
|
||||
@@ -1448,10 +1537,10 @@ public class JavaBuild {
|
||||
File argsFile = new File(destFolder + "/lib/args.txt");
|
||||
PrintWriter pw = PApplet.createWriter(argsFile);
|
||||
|
||||
pw.println(runOptions);
|
||||
|
||||
pw.println(sketch.getName());
|
||||
pw.println(exportClassPath);
|
||||
// Since this is only on Windows, make sure we use Windows CRLF
|
||||
pw.print(runOptions + "\r\n");
|
||||
pw.print(sketch.getName() + "\r\n");
|
||||
pw.print(exportClassPath);
|
||||
|
||||
pw.flush();
|
||||
pw.close();
|
||||
|
||||
@@ -164,6 +164,14 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem("The Processing Foundation");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Base.openURL("http://processing.org/foundation/");
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
item = new JMenuItem("Visit Processing.org");
|
||||
item.addActionListener(new ActionListener() {
|
||||
@@ -249,27 +257,21 @@ public class JavaEditor extends Editor {
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
panel.add(Box.createVerticalStrut(6));
|
||||
|
||||
//Box panel = Box.createVerticalBox();
|
||||
|
||||
//Box labelBox = Box.createHorizontalBox();
|
||||
// String msg = "<html>Click Export to Application to create a standalone, " +
|
||||
// "double-clickable application for the selected plaforms.";
|
||||
|
||||
// String msg = "Export to Application creates a standalone, \n" +
|
||||
// "double-clickable application for the selected plaforms.";
|
||||
String line1 = "Export to Application creates double-clickable,";
|
||||
String line2 = "standalone applications for the selected plaforms.";
|
||||
//String line2 = "standalone applications for the selected plaforms.";
|
||||
String line2 = "standalone application for the current plaform.";
|
||||
JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
|
||||
JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
|
||||
label1.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
label2.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
// label1.setAlignmentX();
|
||||
// label2.setAlignmentX(0);
|
||||
panel.add(label1);
|
||||
panel.add(label2);
|
||||
int wide = label2.getPreferredSize().width;
|
||||
// The longer line is different between Windows and OS X.
|
||||
int wide = Math.max(label1.getPreferredSize().width,
|
||||
label2.getPreferredSize().width);
|
||||
panel.add(Box.createVerticalStrut(12));
|
||||
|
||||
/*
|
||||
final JCheckBox windowsButton = new JCheckBox("Windows");
|
||||
//windowsButton.setMnemonic(KeyEvent.VK_W);
|
||||
windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
|
||||
@@ -310,11 +312,12 @@ public class JavaEditor extends Editor {
|
||||
wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
panel.add(platformPanel);
|
||||
*/
|
||||
|
||||
// Box indentPanel = Box.createHorizontalBox();
|
||||
// indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
|
||||
//int indent = new JCheckBox().getPreferredSize().width;
|
||||
int indent = 0;
|
||||
|
||||
final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
|
||||
//showStopButton.setMnemonic(KeyEvent.VK_S);
|
||||
showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
|
||||
showStopButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -322,12 +325,9 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
});
|
||||
showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
|
||||
// indentPanel.add(showStopButton);
|
||||
// indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13 + indent, 6, 13));
|
||||
|
||||
final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
|
||||
//fullscreenButton.setMnemonic(KeyEvent.VK_F);
|
||||
fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
|
||||
fullScreenButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -338,16 +338,36 @@ public class JavaEditor extends Editor {
|
||||
});
|
||||
fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
boolean embed = Preferences.getBoolean("export.application.embed_java");
|
||||
final String embedWarning = "Embedding Java makes larger applications";
|
||||
final String nopeWarning = "Users will have to install the latest Java 7";
|
||||
final JLabel warningLabel = new JLabel(embed ? embedWarning : nopeWarning);
|
||||
warningLabel.setBorder(new EmptyBorder(3, 13 + indent, 3, 13));
|
||||
|
||||
final JCheckBox embedJavaButton = new JCheckBox("Embed Java");
|
||||
embedJavaButton.setSelected(embed);
|
||||
embedJavaButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
boolean selected = embedJavaButton.isSelected();
|
||||
Preferences.setBoolean("export.application.embed_java", selected);
|
||||
if (selected) {
|
||||
warningLabel.setText(embedWarning);
|
||||
} else {
|
||||
warningLabel.setText(nopeWarning);
|
||||
}
|
||||
}
|
||||
});
|
||||
embedJavaButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
JPanel optionPanel = new JPanel();
|
||||
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
|
||||
optionPanel.add(fullScreenButton);
|
||||
optionPanel.add(showStopButton);
|
||||
// optionPanel.add(indentPanel);
|
||||
optionPanel.add(embedJavaButton);
|
||||
optionPanel.add(warningLabel);
|
||||
optionPanel.setBorder(new TitledBorder("Options"));
|
||||
wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
//goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
|
||||
// wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
//optionPanel.setMaximumSize(goodIdea);
|
||||
panel.add(optionPanel);
|
||||
|
||||
Dimension good;
|
||||
@@ -356,43 +376,20 @@ public class JavaEditor extends Editor {
|
||||
label1.setMaximumSize(good);
|
||||
good = new Dimension(wide, label2.getPreferredSize().height);
|
||||
label2.setMaximumSize(good);
|
||||
good = new Dimension(wide, platformPanel.getPreferredSize().height);
|
||||
platformPanel.setMaximumSize(good);
|
||||
// good = new Dimension(wide, platformPanel.getPreferredSize().height);
|
||||
// platformPanel.setMaximumSize(good);
|
||||
good = new Dimension(wide, optionPanel.getPreferredSize().height);
|
||||
optionPanel.setMaximumSize(good);
|
||||
// optionPanel.setMaximumSize(good);
|
||||
|
||||
// JPanel actionPanel = new JPanel();
|
||||
// optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
|
||||
// optionPanel.add(Box.createHorizontalGlue());
|
||||
|
||||
// final JDialog frame = new JDialog(editor, "Export to Application");
|
||||
|
||||
// JButton cancelButton = new JButton("Cancel");
|
||||
// cancelButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// frame.dispose();
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
// Add the buttons in platform-specific order
|
||||
// if (PApplet.platform == PConstants.MACOSX) {
|
||||
// optionPanel.add(cancelButton);
|
||||
// optionPanel.add(exportButton);
|
||||
// } else {
|
||||
// optionPanel.add(exportButton);
|
||||
// optionPanel.add(cancelButton);
|
||||
// }
|
||||
String[] options = { "Export", "Cancel" };
|
||||
final JOptionPane optionPane = new JOptionPane(panel,
|
||||
JOptionPane.PLAIN_MESSAGE,
|
||||
//JOptionPane.QUESTION_MESSAGE,
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
|
||||
final JDialog dialog = new JDialog(this, "Export Options", true);
|
||||
final JDialog dialog = new JDialog(this, "Export Application", true);
|
||||
dialog.setContentPane(optionPane);
|
||||
|
||||
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@@ -402,9 +399,8 @@ public class JavaEditor extends Editor {
|
||||
if (dialog.isVisible() &&
|
||||
(e.getSource() == optionPane) &&
|
||||
(prop.equals(JOptionPane.VALUE_PROPERTY))) {
|
||||
//If you were going to check something
|
||||
//before closing the window, you'd do
|
||||
//it here.
|
||||
// If you were going to check something before
|
||||
// closing the window, you'd do it here.
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,12 @@ public class JavaMode extends Mode {
|
||||
if (coreLibrary == null) {
|
||||
File coreFolder = Base.getContentFile("core");
|
||||
coreLibrary = new Library(coreFolder);
|
||||
// try {
|
||||
// coreLibrary = getLibrary("processing.core");
|
||||
// System.out.println("core found at " + coreLibrary.getLibraryPath());
|
||||
// } catch (SketchException e) {
|
||||
// Base.log("Serious problem while locating processing.core", e);
|
||||
// }
|
||||
}
|
||||
return coreLibrary;
|
||||
}
|
||||
|
||||
@@ -123,11 +123,7 @@ public class Runner implements MessageConsumer {
|
||||
}
|
||||
|
||||
|
||||
// public void launch(String appletClassName, boolean presenting) {
|
||||
// this.appletClassName = appletClassName;
|
||||
public boolean launchVirtualMachine(boolean presenting) {
|
||||
// this.presenting = presenting;
|
||||
|
||||
String[] vmParams = getMachineParams();
|
||||
String[] sketchParams = getSketchParams(presenting);
|
||||
int port = 8000 + (int) (Math.random() * 1000);
|
||||
@@ -139,10 +135,15 @@ public class Runner implements MessageConsumer {
|
||||
// Newer (Java 1.5+) version that uses JVMTI
|
||||
String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y";
|
||||
|
||||
// Everyone works the same under Java 7 (also on OS X)
|
||||
String[] commandArgs = new String[] { Base.getJavaPath(), jdwpArg };
|
||||
|
||||
/*
|
||||
String[] commandArgs = null;
|
||||
if (!Base.isMacOS()) {
|
||||
commandArgs = new String[] {
|
||||
"java", jdwpArg
|
||||
Base.getJavaPath(),
|
||||
jdwpArg
|
||||
};
|
||||
} else {
|
||||
// Decided to just set this to 1.6 only, because otherwise it's gonna
|
||||
@@ -160,56 +161,42 @@ public class Runner implements MessageConsumer {
|
||||
// OS X at this point, because we require 10.6.8 and higher. That also
|
||||
// means we don't need to check for any other OS versions, the user is
|
||||
// a douchebag and modifies Info.plist to get around the restriction.
|
||||
if (System.getProperty("os.version").startsWith("10.6")) {
|
||||
commandArgs = new String[] {
|
||||
"/usr/libexec/java_home",
|
||||
"--version", "1.6",
|
||||
"--exec", "java",
|
||||
"-d" + Base.getNativeBits(),
|
||||
jdwpArg
|
||||
};
|
||||
} else { // for 10.7, 10.8, etc
|
||||
commandArgs = new String[] {
|
||||
"/usr/libexec/java_home",
|
||||
"--request", // install on-demand
|
||||
"--version", "1.6",
|
||||
"--exec", "java",
|
||||
"-d" + Base.getNativeBits(),
|
||||
if (false) {
|
||||
if (System.getProperty("os.version").startsWith("10.6")) {
|
||||
commandArgs = new String[] {
|
||||
"/usr/libexec/java_home",
|
||||
"--version", "1.6",
|
||||
"--exec", "java",
|
||||
"-d" + Base.getNativeBits(),
|
||||
jdwpArg
|
||||
};
|
||||
} else { // for 10.7, 10.8, etc
|
||||
commandArgs = new String[] {
|
||||
"/usr/libexec/java_home",
|
||||
"--request", // install on-demand
|
||||
"--version", "1.6",
|
||||
"--exec", "java",
|
||||
"-d" + Base.getNativeBits(),
|
||||
// debugArg,
|
||||
jdwpArg
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// testing jdk-7u40
|
||||
commandArgs = new String[] {
|
||||
//"/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java",
|
||||
Base.getJavaPath(),
|
||||
jdwpArg
|
||||
};
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
commandArgs = PApplet.concat(commandArgs, vmParams);
|
||||
commandArgs = PApplet.concat(commandArgs, sketchParams);
|
||||
// PApplet.println(commandArgs);
|
||||
// commandArg.setValue(commandArgs);
|
||||
launchJava(commandArgs);
|
||||
// try {
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
// boolean available = false;
|
||||
// while (!available) {
|
||||
// try {
|
||||
// Socket socket = new Socket((String) null, port);
|
||||
//// socket.close();
|
||||
// // this should mean we're all set?
|
||||
// available = true;
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// System.out.println("waiting");
|
||||
// //e.printStackTrace();
|
||||
// try {
|
||||
// Thread.sleep(100);
|
||||
// } catch (InterruptedException e1) {
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
AttachingConnector connector = (AttachingConnector)
|
||||
findConnector("com.sun.jdi.SocketAttach");
|
||||
@@ -459,7 +446,7 @@ public class Runner implements MessageConsumer {
|
||||
// PApplet.println("launchJava stderr:");
|
||||
// PApplet.println(errorStrings);
|
||||
// PApplet.println("launchJava stdout:");
|
||||
PApplet.println(inputStrings);
|
||||
PApplet.printArray(inputStrings);
|
||||
|
||||
if (errorStrings != null && errorStrings.length > 1) {
|
||||
if (errorStrings[0].indexOf("Invalid maximum heap size") != -1) {
|
||||
@@ -806,18 +793,27 @@ public class Runner implements MessageConsumer {
|
||||
// System.out.println("mess type " + messageValue.type());
|
||||
//StringReference messageReference = (StringReference) messageValue.type();
|
||||
|
||||
// System.out.println(or.referenceType().fields());
|
||||
// if (name.startsWith("java.lang.")) {
|
||||
// name = name.substring(10);
|
||||
if (!handleCommonErrors(exceptionName, message, listener)) {
|
||||
reportException(message, or, event.thread());
|
||||
}
|
||||
// First just report the exception and its placement
|
||||
reportException(message, or, event.thread());
|
||||
// Then try to pretty it up with a better message
|
||||
handleCommonErrors(exceptionName, message, listener);
|
||||
|
||||
if (editor != null) {
|
||||
editor.deactivateRun();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provide more useful explanations of common error messages, perhaps with
|
||||
* a short message in the status area, and (if necessary) a longer message
|
||||
* in the console.
|
||||
*
|
||||
* @param exceptionClass Class name causing the error (with full package name)
|
||||
* @param message The message from the exception
|
||||
* @param listener The Editor or command line interface that's listening for errors
|
||||
* @return true if the error was purtified, false otherwise
|
||||
*/
|
||||
public static boolean handleCommonErrors(final String exceptionClass,
|
||||
final String message,
|
||||
final RunnerListener listener) {
|
||||
@@ -837,6 +833,11 @@ public class Runner implements MessageConsumer {
|
||||
System.err.println("If your sketch uses a lot of memory (for instance if it loads a lot of data files)");
|
||||
System.err.println("you can increase the memory available to your sketch using the Preferences window.");
|
||||
}
|
||||
} else if (exceptionClass.equals("java.lang.UnsatisfiedLinkError")) {
|
||||
listener.statusError("A library used by this sketch is not installed properly.");
|
||||
System.err.println("A library relies on native code that's not available.");
|
||||
System.err.println("Or only works properly when the sketch is run as a " +
|
||||
((Base.getNativeBits() == 32) ? "64-bit " : "32-bit ") + " application.");
|
||||
|
||||
} else if (exceptionClass.equals("java.lang.StackOverflowError")) {
|
||||
listener.statusError("StackOverflowError: This sketch is attempting too much recursion.");
|
||||
|
||||
Reference in New Issue
Block a user