use Base.isXxxx() for methods instead of the PApplet versions, work on dist script for release numbering

This commit is contained in:
benfry
2008-11-29 17:22:59 +00:00
parent b3e960b8d3
commit 3415adca8a
8 changed files with 101 additions and 113 deletions

View File

@@ -42,12 +42,7 @@ import processing.core.*;
*/
public class Base {
static final int REVISION = 163;
//static final String REVISION_NAME = "0163";
static final String VERSION_NAME = "1.0 (0163)";
static final int[] platforms = new int[] {
PConstants.WINDOWS, PConstants.MACOSX, PConstants.LINUX
};
static String VERSION_NAME = "0163";
static HashMap<Integer, String> platformNames = new HashMap();
static {
@@ -106,6 +101,15 @@ public class Base {
static public void main(String args[]) {
try {
File versionFile = getContentFile("version.txt");
if (versionFile.exists()) {
VERSION_NAME = PApplet.loadStrings(versionFile)[0];
}
} catch (Exception e) {
e.printStackTrace();
}
// if (System.getProperty("mrj.version") != null) {
// //String jv = System.getProperty("java.version");
// String ov = System.getProperty("os.version");
@@ -839,7 +843,7 @@ public class Base {
// Save out the current prefs state
Preferences.save();
if (PApplet.platform != PConstants.MACOSX) {
if (!Base.isMacOS()) {
// If this was fired from the menu or an AppleEvent (the Finder),
// then Mac OS X will send the terminate signal itself.
System.exit(0);
@@ -1189,11 +1193,47 @@ public class Base {
/**
* Get list of platform constants.
*/
static public int[] getPlatforms() {
return platforms;
// static public int[] getPlatforms() {
// return platforms;
// }
// static public int getPlatform() {
// String osname = System.getProperty("os.name");
//
// if (osname.indexOf("Mac") != -1) {
// return PConstants.MACOSX;
//
// } else if (osname.indexOf("Windows") != -1) {
// return PConstants.WINDOWS;
//
// } else if (osname.equals("Linux")) { // true for the ibm vm
// return PConstants.LINUX;
//
// } else {
// return PConstants.OTHER;
// }
// }
static public String getPlatformName() {
String osname = System.getProperty("os.name");
if (osname.indexOf("Mac") != -1) {
return "macosx";
} else if (osname.indexOf("Windows") != -1) {
return "windows";
} else if (osname.equals("Linux")) { // true for the ibm vm
return "linux";
} else {
return "other";
}
}
/**
* Map a platform constant to its name.
* @param which PConstants.WINDOWS, PConstants.MACOSX, PConstants.LINUX
@@ -1209,12 +1249,18 @@ public class Base {
return (entry == null) ? -1 : entry.intValue();
}
// These were changed to no longer rely on PApplet and PConstants because
// of conflicts that could happen with older versions of core.jar, where
// the MACOSX constant would instead read as the LINUX constant.
/**
* returns true if Processing is running on a Mac OS X machine.
*/
static public boolean isMacOS() {
return PApplet.platform == PConstants.MACOSX;
//return PApplet.platform == PConstants.MACOSX;
return System.getProperty("os.name").indexOf("Mac") != -1;
}
@@ -1222,7 +1268,8 @@ public class Base {
* returns true if running on windows.
*/
static public boolean isWindows() {
return PApplet.platform == PConstants.WINDOWS;
//return PApplet.platform == PConstants.WINDOWS;
return System.getProperty("os.name").indexOf("Windows") != -1;
}
@@ -1230,7 +1277,8 @@ public class Base {
* true if running on linux.
*/
static public boolean isLinux() {
return PApplet.platform == PConstants.LINUX;
//return PApplet.platform == PConstants.LINUX;
return System.getProperty("os.name").indexOf("Linux") != -1;
}
@@ -1664,7 +1712,7 @@ public class Base {
String path = System.getProperty("user.dir");
// Get a path to somewhere inside the .app folder
if (PApplet.platform == PConstants.MACOSX) {
if (Base.isMacOS()) {
// <key>javaroot</key>
// <string>$JAVAROOT</string>
String javaroot = System.getProperty("javaroot");

View File

@@ -50,9 +50,6 @@ public class Editor extends JFrame implements RunnerListener {
Base base;
// yeah
static final String WINDOW_TITLE = "Processing " + Base.VERSION_NAME;
// otherwise, if the window is resized with the message label
// set to blank, it's preferredSize() will be fukered
static protected final String EMPTY =
@@ -130,7 +127,7 @@ public class Editor extends JFrame implements RunnerListener {
public Editor(Base ibase, String path, int[] location) {
super(WINDOW_TITLE);
super("Processing");
this.base = ibase;
Base.setIcon(this);
@@ -576,22 +573,14 @@ public class Editor extends JFrame implements RunnerListener {
}
sketchMenu.add(importMenu);
//if (Base.isWindows() || Base.isMacOS()) {
// no way to do an 'open in file browser' on other platforms
// since there isn't any sort of standard
item = newJMenuItem("Show Sketch Folder", 'K');
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//Base.openFolder(sketchDir);
Base.openFolder(sketch.getFolder());
}
});
sketchMenu.add(item);
if (!Base.openFolderAvailable()) {
item.setEnabled(false);
}
//menu.addSeparator();
item.setEnabled(Base.openFolderAvailable());
item = new JMenuItem("Add File...");
item.addActionListener(new ActionListener() {
@@ -601,8 +590,6 @@ public class Editor extends JFrame implements RunnerListener {
});
sketchMenu.add(item);
// TODO re-enable history
//history.attachMenu(menu);
return sketchMenu;
}
@@ -776,29 +763,6 @@ public class Editor extends JFrame implements RunnerListener {
protected JMenu addInternalTools(JMenu menu) {
JMenuItem item;
/*
item = newJMenuItem("Auto Format", 'T');
item.addActionListener(new ActionListener() {
synchronized public void actionPerformed(ActionEvent e) {
Jalopy jalopy = new Jalopy();
jalopy.setInput(getText(), sketch.current.file.getAbsolutePath());
StringBuffer buffer = new StringBuffer();
jalopy.setOutput(buffer);
jalopy.setInspect(false);
jalopy.format();
setText(buffer.toString(), 0, 0);
if (jalopy.getState() == Jalopy.State.OK)
System.out.println("successfully formatted");
else if (jalopy.getState() == Jalopy.State.WARN)
System.out.println(" formatted with warnings");
else if (jalopy.getState() == Jalopy.State.ERROR)
System.out.println(" could not be formatted");
}
});
menu.add(item);
*/
item = createToolMenuItem("processing.app.tools.AutoFormat");
int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
item.setAccelerator(KeyStroke.getKeyStroke('T', modifiers));
@@ -809,38 +773,6 @@ public class Editor extends JFrame implements RunnerListener {
menu.add(createToolMenuItem("processing.app.tools.Archiver"));
menu.add(createToolMenuItem("processing.app.tools.FixEncoding"));
/*
item = new JMenuItem("Export Folder...");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new ExportFolder(Editor.this).show();
}
});
}
});
menu.add(item);
*/
/*
item = new JMenuItem("Open in External Editor");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Preferences.setBoolean("editor.external", true);
applyPreferences();
String path = sketch.current.file.getAbsolutePath();
try {
Runtime.getRuntime().exec(new String[] {
"cmd", "/c", "c:\\emacs-20.7\\bin\\runemacs.exe", path
});
} catch (Exception ex) { }
}
});
menu.add(item);
*/
return menu;
}
@@ -1724,7 +1656,7 @@ public class Editor extends JFrame implements RunnerListener {
String prompt = "Save changes to " + sketch.getName() + "? ";
if (PApplet.platform != PConstants.MACOSX) {
if (!Base.isMacOS()) {
int result =
JOptionPane.showConfirmDialog(this, prompt, "Close",
JOptionPane.YES_NO_CANCEL_OPTION,
@@ -1903,7 +1835,7 @@ public class Editor extends JFrame implements RunnerListener {
}
header.rebuild();
// Set the title of the window to "sketch_070752a - Processing 0126"
setTitle(sketch.getName() + " | " + WINDOW_TITLE);
setTitle(sketch.getName() + " | Processing " + Base.VERSION_NAME);
// Disable untitled setting from previous document, if any
untitled = false;

View File

@@ -641,7 +641,7 @@ public class Sketch {
}
editor.header.repaint();
if (PApplet.platform == PConstants.MACOSX) {
if (Base.isMacOS()) {
// http://developer.apple.com/qa/qa2001/qa1146.html
Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE;
editor.getRootPane().putClientProperty("windowModified", modifiedParam);
@@ -1735,7 +1735,7 @@ public class Sketch {
String dataFiles[] = Base.listFiles(dataFolder, false);
int offset = folder.getAbsolutePath().length() + 1;
for (int i = 0; i < dataFiles.length; i++) {
if (PApplet.platform == PApplet.WINDOWS) {
if (Base.isWindows()) {
dataFiles[i] = dataFiles[i].replace('\\', '/');
}
File dataFile = new File(dataFiles[i]);
@@ -2179,10 +2179,10 @@ public class Sketch {
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..
if (PApplet.platform == PConstants.WINDOWS) {
if (Base.isWindows()) {
File warningFile = new File(destFolder, "readme.txt");
PrintWriter pw = PApplet.createWriter(warningFile);
pw.println("This application was created on Windows, which doesn't");
pw.println("This application was created on Windows, which does not");
pw.println("properly support setting files as \"executable\",");
pw.println("a necessity for applications on Mac OS X.");
pw.println();
@@ -2253,7 +2253,7 @@ public class Sketch {
String dataFiles[] = Base.listFiles(dataFolder, false);
int offset = folder.getAbsolutePath().length() + 1;
for (int i = 0; i < dataFiles.length; i++) {
if (PApplet.platform == PApplet.WINDOWS) {
if (Base.isWindows()) {
dataFiles[i] = dataFiles[i].replace('\\', '/');
}
File dataFile = new File(dataFiles[i]);
@@ -2478,7 +2478,7 @@ public class Sketch {
String shellPath = shellScript.getAbsolutePath();
// will work on osx or *nix, but just dies on windows, oh well..
if (PApplet.platform != PConstants.WINDOWS) {
if (!Base.isWindows()) {
Runtime.getRuntime().exec(new String[] { "chmod", "+x", shellPath });
}
}

View File

@@ -53,7 +53,7 @@ public class Theme {
}
// check for platform-specific properties in the defaults
String platformExt = "." + PConstants.platformNames[PApplet.platform];
String platformExt = "." + Base.getPlatformName();
int platformExtLength = platformExt.length();
Enumeration e = table.keys();
while (e.hasMoreElements()) {

View File

@@ -379,7 +379,7 @@ public class Runner implements MessageConsumer {
//String addr = "localhost:" + (8000 + (int) (Math.random() * 1000));
//String addr = "" + (8000 + (int) (Math.random() * 1000));
String commandArgs = (PApplet.platform == PConstants.WINDOWS) ?
String commandArgs = Base.isWindows() ?
"java -Xrunjdwp:transport=dt_shmem,address=" + addr + ",suspend=y " :
"java -Xrunjdwp:transport=dt_socket,address=" + addr + ",suspend=y ";
//String commandArgs = "java -agentlib:jdwp=transport=dt_socket,address=" + addr + ",suspend=y ";

View File

@@ -1609,12 +1609,12 @@ public class JEditTextArea extends JComponent
switch(evt.getID()) {
case KeyEvent.KEY_TYPED:
if ((editorListener != null) && !editorListener.keyTyped(evt)) {
if ((editorListener == null) || !editorListener.keyTyped(evt)) {
inputHandler.keyTyped(evt);
}
break;
case KeyEvent.KEY_PRESSED:
if ((editorListener != null) && !editorListener.keyPressed(evt)) {
if ((editorListener == null) || !editorListener.keyPressed(evt)) {
inputHandler.keyPressed(evt);
}
break;

View File

@@ -27,6 +27,11 @@ rm -rf work
./make.sh
if [ $1 ]
then
# write the release version number into the output directory
echo $1 > work/Processing.app/Contents/Resources/Java/lib/version.txt
fi
echo Cleaning file boogers...

View File

@@ -1,4 +1,22 @@
0163 pde
X ArrayIndexOutOfBoundsException with File > New (Processing 1.0)
X maybe a /tmp permissions problem?
X are we not checking errors properly on this route?
X http://dev.processing.org/bugs/show_bug.cgi?id=1067
X need to look into why this didn't give a better error message
X "[JavaAppLauncher Error] CallStaticVoidMethod() threw an exception"
X on startup with OS X
X http://dev.processing.org/bugs/show_bug.cgi?id=1063
X http://dev.processing.org/bugs/show_bug.cgi?id=1078
X Fix some "An error occurred while starting the application" problems
X due to the weird sketch folder naming issue
X implement multi-line tab via tab key (also outdent)
o add preference for indent size
X the bracket isn't working on osx because of an apple menu bug
X http://dev.processing.org/bugs/show_bug.cgi?id=1075
X "editor.indent" setting does not work properly
X http://dev.processing.org/bugs/show_bug.cgi?id=1073
_ the changes page doesn't have a toc entry for the 1.0 release notes
_ add minim to the changes page
_ windows bug is the biggest problem
@@ -7,24 +25,11 @@ _ check if libraries folder does not exist
_ check to see if other libraries are installed
_ warn user about moving libraries and restarting
_ implement multi-line tab via tab key (also outdent)
_ add preference for indent size
_ http://dev.processing.org/bugs/show_bug.cgi?id=1075
1 _ "An error occurred while starting the application" with Processing 0154+
1 _ Maybe provide the old exe or another alternative?
1 _ Have someone try this on lab machines until we can find one that breaks
1 _ http://dev.processing.org/bugs/show_bug.cgi?id=986
1 _ might be related to bug #1063 (below)
1 _ need to do a better job of error handling inside main()
1 _ "[JavaAppLauncher Error] CallStaticVoidMethod() threw an exception"
1 _ on startup with OS X
1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1063
1 X ArrayIndexOutOfBoundsException with File > New (Processing 1.0)
1 X maybe a /tmp permissions problem?
1 X are we not checking errors properly on this route?
1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1067
1 _ need to look into why this didn't give a better error message
1 _ need to do a better job of error handling inside main()
not /as/ important, but soon
@@ -33,8 +38,6 @@ not /as/ important, but soon
4 _ http://dev.processing.org/bugs/show_bug.cgi?id=1065
2 _ "space-import-space-quote-semicolon" Causes Error in String or Comment
2 _ http://dev.processing.org/bugs/show_bug.cgi?id=1064
5 _ "editor.indent" setting does not work properly
5 _ http://dev.processing.org/bugs/show_bug.cgi?id=1073
[ needs verification ]