fixing up some prefs stuff, add run.options, don't launch prefs txt file

from inside p5, fixing up runner, adding more info to the faq
This commit is contained in:
benfry
2005-04-18 18:54:26 +00:00
parent d5c79848bf
commit 84242ce7bc
9 changed files with 346 additions and 278 deletions
+2 -2
View File
@@ -50,8 +50,8 @@ import processing.core.*;
* files and images, etc) that comes from that.
*/
public class Base {
static final int VERSION = 83;
static final String VERSION_NAME = "0083 Alpha";
static final int VERSION = 84;
static final String VERSION_NAME = "0084 Alpha";
/**
* Path of filename opened on the command line,
+22 -7
View File
@@ -169,10 +169,10 @@ public class Preferences extends JComponent {
} catch (Exception ex) {
Base.showError("Error reading preferences",
"Error reading the preferences file. " +
"Please delete (or move)\n" +
preferencesFile.getAbsolutePath() +
" and restart Processing.", ex);
"Error reading the preferences file. " +
"Please delete (or move)\n" +
preferencesFile.getAbsolutePath() +
" and restart Processing.", ex);
}
}
}
@@ -343,17 +343,32 @@ public class Preferences extends JComponent {
top += d.height; // + GUI_SMALL;
label = new JLabel(preferencesFile.getAbsolutePath());
/*
label.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
// close the frame and ignore any changes.
// otherwise, any changes made to preferences.txt
// will be lost when the prefs window is closed,
// since things will be re-applied.
disposeFrame();
// now safe to open the text file
Base.openURL(preferencesFile.getAbsolutePath());
}
});
label.setForeground(new Color(51, 25, 153));
*/
//label.setForeground(new Color(51, 25, 153));
pain.add(label);
d = label.getPreferredSize();
label.setBounds(left, top, d.width, d.height);
//textarea.setBounds(left, top, d.width, d.height);
//top += d.height; // + GUI_BETWEEN;
label = new JLabel("(edit only when Processing is not running)");
pain.add(label);
d = label.getPreferredSize();
label.setForeground(Color.gray);
label.setBounds(left, top, d.width, d.height);
top += d.height; // + GUI_SMALL;
// [ OK ] [ Cancel ] maybe these should be next to the message?
+82 -39
View File
@@ -29,6 +29,7 @@ import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import com.oroinc.text.regex.*;
@@ -94,24 +95,44 @@ public class Runner implements MessageConsumer {
public void startPresenting() throws Exception {
String command[] = new String[] {
"java",
"-Djava.library.path=" +
sketch.libraryPath +
File.pathSeparator + System.getProperty("java.library.path"),
"-cp",
sketch.classPath + Sketchbook.librariesClassPath,
"processing.core.PApplet",
PApplet.ARGS_EXTERNAL,
PApplet.ARGS_PRESENT,
PApplet.ARGS_PRESENT_BGCOLOR + "=" +
Preferences.get("run.present.bgcolor"),
PApplet.ARGS_DISPLAY + "=" +
Preferences.get("run.display"),
PApplet.ARGS_SKETCH_FOLDER + "=" +
sketch.folder.getAbsolutePath(),
sketch.mainClassName
};
Vector params = new Vector();
params.add("java");
String options = Preferences.get("run.options");
if (options.length() > 0) {
String pieces[] = PApplet.split(options, ' ');
for (int i = 0; i < pieces.length; i++) {
String p = pieces[i].trim();
if (p.length() > 0) {
params.add(p);
}
}
}
params.add("-Djava.library.path=" +
sketch.libraryPath +
File.pathSeparator +
System.getProperty("java.library.path"));
params.add("-cp");
params.add(sketch.classPath + Sketchbook.librariesClassPath);
params.add("processing.core.PApplet");
params.add(PApplet.ARGS_EXTERNAL);
params.add(PApplet.ARGS_PRESENT);
params.add(PApplet.ARGS_PRESENT_BGCOLOR + "=" +
Preferences.get("run.present.bgcolor"));
params.add(PApplet.ARGS_DISPLAY + "=" +
Preferences.get("run.display"));
params.add(PApplet.ARGS_SKETCH_FOLDER + "=" +
sketch.folder.getAbsolutePath());
params.add(sketch.mainClassName);
String command[] = new String[params.size()];
params.copyInto(command);
//PApplet.println(command);
process = Runtime.getRuntime().exec(command);
processInput = new SystemOutSiphon(process.getInputStream());
@@ -134,27 +155,49 @@ public class Runner implements MessageConsumer {
(PApplet.ARGS_EDITOR_LOCATION + "=" +
editorLocation.x + "," + editorLocation.y);
//System.out.println("library path is " + sketch.libraryPath);
String command[] = new String[] {
// this made the code folder bug go away, but killed stdio
//"cmd", "/c", "start",
"java",
"-Djava.library.path=" +
// sketch.libraryPath might be ""
// librariesClassPath will always have sep char prepended
sketch.libraryPath +
File.pathSeparator + System.getProperty("java.library.path"),
"-cp",
sketch.classPath + Sketchbook.librariesClassPath,
"processing.core.PApplet",
location,
PApplet.ARGS_EXTERNAL,
PApplet.ARGS_DISPLAY + "=" + Preferences.get("run.display"),
PApplet.ARGS_SKETCH_FOLDER + "=" + sketch.folder.getAbsolutePath(),
sketch.mainClassName
};
//PApplet.printarr(command);
//PApplet.println(PApplet.join(command, " "));
// this as prefix made the code folder bug go away, but killed stdio
//"cmd", "/c", "start",
// all params have to be stored as separate items,
// so a growable array needs to be used. i.e. -Xms128m -Xmx1024m
// will throw an error if it's shoved into a single array element
Vector params = new Vector();
params.add("java");
String options = Preferences.get("run.options");
if (options.length() > 0) {
String pieces[] = PApplet.split(options, ' ');
for (int i = 0; i < pieces.length; i++) {
String p = pieces[i].trim();
if (p.length() > 0) {
params.add(p);
}
}
}
// sketch.libraryPath might be ""
// librariesClassPath will always have sep char prepended
params.add("-Djava.library.path=" +
sketch.libraryPath +
File.pathSeparator +
System.getProperty("java.library.path"));
params.add("-cp");
params.add(sketch.classPath + Sketchbook.librariesClassPath);
params.add("processing.core.PApplet");
params.add(location);
params.add(PApplet.ARGS_EXTERNAL);
params.add(PApplet.ARGS_DISPLAY + "=" +
Preferences.get("run.display"));
params.add(PApplet.ARGS_SKETCH_FOLDER + "=" +
sketch.folder.getAbsolutePath());
params.add(sketch.mainClassName);
String command[] = new String[params.size()];
params.copyInto(command);
//PApplet.println(command);
process = Runtime.getRuntime().exec(command);
processInput = new SystemOutSiphon(process.getInputStream());