diff --git a/app/src/antlr/ExtendedCommonASTWithHiddenTokens.java b/app/src/antlr/ExtendedCommonASTWithHiddenTokens.java index 43519e89c..dcbaa7586 100644 --- a/app/src/antlr/ExtendedCommonASTWithHiddenTokens.java +++ b/app/src/antlr/ExtendedCommonASTWithHiddenTokens.java @@ -8,9 +8,9 @@ package antlr; */ import java.io.*; -import antlr.*; +//import antlr.*; import antlr.collections.*; -import antlr.collections.impl.*; +//import antlr.collections.impl.*; /** A CommonAST whose initialization copies hidden token * information from the Token used to create a node. diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 9231e8925..3920ff374 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -27,14 +27,14 @@ import java.awt.*; import java.awt.event.*; import java.io.*; import java.lang.reflect.*; -import java.net.*; +//import java.net.*; import java.util.*; -import java.util.zip.*; +//import java.util.zip.*; import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; -import javax.swing.undo.*; +//import javax.swing.event.*; +//import javax.swing.text.*; +//import javax.swing.undo.*; import com.apple.mrj.*; import com.ice.jni.registry.*; @@ -174,7 +174,7 @@ public class Base { if (PApplet.platform == PConstants.MACOSX) { MRJOpenDocumentHandler startupOpen = new MRJOpenDocumentHandler() { public void handleOpenFile(File file) { - handleOpen(file.getAbsolutePath()); + handleOpen(file); // this will only get set once.. later will be handled // by the Editor version of this fella //if (Base.openedAtStartup == null) { @@ -188,13 +188,13 @@ public class Base { // #@$*(@#$ apple.. always gotta think different MRJApplicationUtils.registerAboutHandler(new MRJAboutHandler() { public void handleAbout() { - Editor.handleAbout(); + activeEditor.handleAbout(); } }); MRJApplicationUtils.registerPrefsHandler(new MRJPrefsHandler() { public void handlePrefs() { - Editor.handlePrefs(); + activeEditor.handlePrefs(); } }); @@ -276,7 +276,7 @@ public class Base { // get the frontmost window frame for placing file dialog //static public void handleOpen(Frame frame) { - FileDialog od = new FileDialog(frame, + FileDialog od = new FileDialog(activeEditor, "Select a file:", FileDialog.LOAD); //od.setDirectory(new File("../2005/").getAbsolutePath()); @@ -286,10 +286,15 @@ public class Base { String filename = od.getFile(); if (filename == null) return; File inputFile = new File(directory, filename); - handleOpen(inputFile); + handleOpen(inputFile.getAbsolutePath()); } + public void handleOpen(File file) { + handleOpen(file.getAbsolutePath()); + } + + public void handleOpen(String path) { new Editor(this, path); } @@ -804,7 +809,7 @@ public class Base { //fd.setFile(folder.getName()); } System.setProperty("apple.awt.fileDialogForDirectories", "true"); - fd.show(); + fd.setVisible(true); System.setProperty("apple.awt.fileDialogForDirectories", "false"); if (fd.getFile() == null) { return null; @@ -1042,7 +1047,7 @@ public class Base { // Attempt to use gnome-open try { Process p = Runtime.getRuntime().exec(new String[] { "gnome-open" }); - int result = p.waitFor(); + /*int result =*/ p.waitFor(); // Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04) Preferences.set("launcher.linux", "gnome-open"); return true; @@ -1051,7 +1056,7 @@ public class Base { // Attempt with kde-open try { Process p = Runtime.getRuntime().exec(new String[] { "kde-open" }); - int result = p.waitFor(); + /*int result =*/ p.waitFor(); Preferences.set("launcher.linux", "kde-open"); return true; } catch (Exception e) { } diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 4c9ddeea5..06eca0689 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -30,23 +30,23 @@ import processing.core.*; import java.awt.*; import java.awt.datatransfer.*; -import java.awt.dnd.*; +//import java.awt.dnd.*; import java.awt.event.*; import java.awt.print.*; import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; -import java.util.zip.*; +//import java.lang.reflect.*; +//import java.net.*; +//import java.util.*; +//import java.util.zip.*; import javax.swing.*; -import javax.swing.border.*; +//import javax.swing.border.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.undo.*; -import com.apple.mrj.*; -import com.oroinc.text.regex.*; +//import com.apple.mrj.*; +//import com.oroinc.text.regex.*; //import de.hunsicker.jalopy.*; @@ -129,11 +129,9 @@ public class Editor extends JFrame { FindReplace find; - public Editor(Base base, String path) { + public Editor(Base ibase, String path) { super(WINDOW_TITLE); - - this.base = base; - + this.base = ibase; // set the window icon if (icon == null) { @@ -159,7 +157,7 @@ public class Editor extends JFrame { // When bringing a window to front, let the Base know addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { - base.setFrontEditor(this); + base.handleActivated(Editor.this); } }); @@ -270,7 +268,7 @@ public class Editor extends JFrame { String name = filename.substring(0, filename.length() - 4); File parent = file.getParentFile(); if (name.equals(parent.getName())) { - Base.handleOpenFile(file); + base.handleOpen(file); return true; } } @@ -307,7 +305,7 @@ public class Editor extends JFrame { // Open the document that was passed in handleOpen(path); // show the window - show(); + setVisible(true); } @@ -1356,19 +1354,19 @@ public class Editor extends JFrame { // @return false if canceling the close/quit operation - protected boolean checkModified() { - if (!modified) return true; + protected boolean checkModified(boolean quitting) { + if (!sketch.modified) return true; - String prompt = "Save changes to " + file.getName() + "? "; + String prompt = "Save changes to " + sketch.name + "? "; if (PApplet.platform != PConstants.MACOSX || PApplet.javaVersion < 1.5f) { int result = - JOptionPane.showConfirmDialog(frame, prompt, "Close", + JOptionPane.showConfirmDialog(this, prompt, "Close", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { - return handleSave(); + return handleSave(quitting); } else if (result == JOptionPane.NO_OPTION) { return true; // ok to continue @@ -1414,12 +1412,12 @@ public class Editor extends JFrame { pane.putClientProperty("Quaqua.OptionPane.destructiveOption", new Integer(2)); - JDialog dialog = pane.createDialog(frame, null); + JDialog dialog = pane.createDialog(this, null); dialog.setVisible(true); Object result = pane.getValue(); if (result == options[0]) { // save (and close/quit) - return handleSave(); + return handleSave(quitting); } else if (result == options[2]) { // don't save (still close/quit) return true; @@ -1570,14 +1568,19 @@ public class Editor extends JFrame { // a way to get started. shite. now i hate myself. //if (disablePrompt) prompt = false; - String path = null; - if (prompt) { - path = sketchbook.handleNewPrompt(); - } else { - path = sketchbook.handleNewUntitled(); - } - if (filename != null) { - base.handleOpen(path); + try { + String path = null; + if (prompt) { + path = sketchbook.handleNewPrompt(); + } else { + path = sketchbook.handleNewUntitled(); + } + if (path != null) { + base.handleOpen(path); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } @@ -1788,6 +1791,17 @@ public class Editor extends JFrame { error(e); } } + + + /* + public boolean handleClose() { + } + */ + + + public void handleClose2() { + base.handleClose(this); + } /** @@ -1799,9 +1813,12 @@ public class Editor extends JFrame { * won't run properly while a quit is happening. This fixes * Bug 276. */ - public void handleSave(boolean immediately) { + public boolean handleSave(boolean immediately) { doStop(); - buttons.activate(EditorButtons.SAVE); + + if (sketch.untitled) { + // need to get the name, user might also cancel here + } if (immediately) { handleSave2(); @@ -1812,10 +1829,12 @@ public class Editor extends JFrame { } }); } + return true; } protected void handleSave2() { + buttons.activate(EditorButtons.SAVE); message("Saving..."); try { if (sketch.save()) { @@ -2013,7 +2032,7 @@ public class Editor extends JFrame { // instead use doClose() which will kill the external vm doClose(); - checkModified(HANDLE_QUIT); + checkModified(true); } diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java index 21c4d6fb8..d24a3ae6e 100644 --- a/app/src/processing/app/EditorStatus.java +++ b/app/src/processing/app/EditorStatus.java @@ -31,7 +31,7 @@ import javax.swing.*; /** * Panel just below the editing area that contains status messages. */ -public class EditorStatus extends JPanel implements ActionListener { +public class EditorStatus extends JPanel /*implements ActionListener*/ { static Color bgcolor[]; static Color fgcolor[]; @@ -117,6 +117,7 @@ public class EditorStatus extends JPanel implements ActionListener { } + /* public void prompt(String message) { mode = PROMPT; this.message = message; @@ -138,6 +139,7 @@ public class EditorStatus extends JPanel implements ActionListener { cancelButton.setVisible(false); empty(); } + */ public void edit(String message, String dflt) { @@ -238,6 +240,26 @@ public class EditorStatus extends JPanel implements ActionListener { cancelButton = new JButton(Preferences.PROMPT_CANCEL); okButton = new JButton(Preferences.PROMPT_OK); + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mode == EDIT) { + unedit(); + editor.buttons.clear(); + } + } + }); + + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // answering to rename/new code question + if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary + String answer = editField.getText(); + editor.sketch.nameCode(answer); + unedit(); + } + } + }); + // !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)( // os9 seems to work if bg of component is set, but x still a bastard if (Base.isMacOS()) { @@ -248,10 +270,12 @@ public class EditorStatus extends JPanel implements ActionListener { } setLayout(null); + /* yesButton.addActionListener(this); noButton.addActionListener(this); cancelButton.addActionListener(this); okButton.addActionListener(this); + */ add(yesButton); add(noButton); @@ -264,7 +288,8 @@ public class EditorStatus extends JPanel implements ActionListener { okButton.setVisible(false); editField = new JTextField(); - editField.addActionListener(this); + // disabling, was not in use + //editField.addActionListener(this); //if (Base.platform != Base.MACOSX) { editField.addKeyListener(new KeyAdapter() { @@ -407,6 +432,20 @@ public class EditorStatus extends JPanel implements ActionListener { public void actionPerformed(ActionEvent e) { + if (e.getSource() == cancelButton) { + if (mode == EDIT) unedit(); + editor.buttons.clear(); + + } else if (e.getSource() == okButton) { + // answering to rename/new code question + if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary + String answer = editField.getText(); + editor.sketch.nameCode(answer); + unedit(); + } + } + + /* if (e.getSource() == noButton) { // shut everything down, clear status, and return unprompt(); @@ -432,5 +471,6 @@ public class EditorStatus extends JPanel implements ActionListener { editor.sketch.nameCode(answer); unedit(); } + */ } } diff --git a/app/src/processing/app/Runner.java b/app/src/processing/app/Runner.java index 92bfe74df..d4f194f15 100644 --- a/app/src/processing/app/Runner.java +++ b/app/src/processing/app/Runner.java @@ -248,8 +248,8 @@ public class Runner implements MessageConsumer { window = new Frame(sketch.name); // use ugly window ((Frame)window).setResizable(false); - if (editor.icon != null) { - ((Frame)window).setIconImage(editor.icon); + if (Editor.icon != null) { + ((Frame)window).setIconImage(Editor.icon); } window.pack(); // to get a peer, size set later, need for insets diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index f0ba04f61..fd7485c7b 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -27,6 +27,7 @@ import processing.app.preproc.*; import processing.core.*; import java.awt.*; +import java.awt.event.WindowEvent; import java.io.*; import java.util.*; import java.util.zip.*; @@ -59,6 +60,11 @@ public class Sketch { * true if any of the files have been modified. */ boolean modified; + + /** + * true if this file has not yet been given a name by the user + */ + boolean untitled; public File folder; public File dataFolder; @@ -587,7 +593,8 @@ public class Sketch { //sketchbook.rebuildMenus(); // make a new sketch, and i think this will rebuild the sketch menu - editor.handleNewUnchecked(); + //editor.handleNewUnchecked(); + editor.handleClose2(); } else { // delete the file @@ -730,8 +737,12 @@ public class Sketch { //new Exception().printStackTrace(); current.modified = state; calcModified(); - Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE; - getRootPane().putClientProperty(WINDOW_MODIFIED, modifiedParam); + + if (PApplet.platform == PConstants.MACOSX) { + // http://developer.apple.com/qa/qa2001/qa1146.html + Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE; + editor.getRootPane().putClientProperty("windowModified", modifiedParam); + } } @@ -948,7 +959,7 @@ public class Sketch { "Select an image or other data file to copy to your sketch"; //FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD); FileDialog fd = new FileDialog(editor, prompt, FileDialog.LOAD); - fd.show(); + fd.setVisible(true); String directory = fd.getDirectory(); String filename = fd.getFile(); diff --git a/app/src/processing/app/Sketchbook.java b/app/src/processing/app/Sketchbook.java index f92cdc926..03194b447 100644 --- a/app/src/processing/app/Sketchbook.java +++ b/app/src/processing/app/Sketchbook.java @@ -26,17 +26,17 @@ package processing.app; import java.awt.*; import java.awt.event.*; import java.io.*; -import java.net.*; +//import java.net.*; import java.text.*; import java.util.*; -import java.util.zip.*; +//import java.util.zip.*; import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; -import javax.swing.undo.*; +//import javax.swing.event.*; +//import javax.swing.text.*; +//import javax.swing.undo.*; -import com.apple.mrj.*; +//import com.apple.mrj.*; /** @@ -155,7 +155,7 @@ public class Sketchbook { "Create sketch folder named:", FileDialog.SAVE); //fd.setDirectory(getSketchbookPath()); - fd.show(); + fd.setVisible(true); String newbieParentDir = fd.getDirectory(); newbieName = fd.getFile(); @@ -163,7 +163,7 @@ public class Sketchbook { newbieName = sanitizeName(newbieName); newbieDir = new File(newbieParentDir, newbieName); - handleNewInternal(newbieDir, newbieName); + return handleNewInternal(newbieDir, newbieName); } @@ -188,11 +188,11 @@ public class Sketchbook { newbieDir = new File(newbieParentDir, newbieName); index++; } while (newbieDir.exists()); - handleNewInternal(newbieDir, newbieName); + return handleNewInternal(newbieDir, newbieName); } - protected String handleNewImpl(File newbieDir, String newbieName) { + protected String handleNewInternal(File newbieDir, String newbieName) throws FileNotFoundException { // make the directory for the new sketch newbieDir.mkdirs(); diff --git a/app/src/processing/app/UpdateCheck.java b/app/src/processing/app/UpdateCheck.java index 36f58408b..11498b705 100644 --- a/app/src/processing/app/UpdateCheck.java +++ b/app/src/processing/app/UpdateCheck.java @@ -22,23 +22,16 @@ package processing.app; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; -import java.util.zip.*; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLEncoder; +import java.util.Random; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; -import javax.swing.undo.*; +import javax.swing.JOptionPane; -import com.apple.mrj.*; -import com.ice.jni.registry.*; - -import processing.core.*; +import processing.core.PApplet; /** diff --git a/app/src/processing/app/preproc/PdeEmitter.java b/app/src/processing/app/preproc/PdeEmitter.java index 35900d515..f642c9c5a 100644 --- a/app/src/processing/app/preproc/PdeEmitter.java +++ b/app/src/processing/app/preproc/PdeEmitter.java @@ -28,7 +28,7 @@ public class PdeEmitter implements PdeTokenTypes { private PrintStream out = System.out; private PrintStream debug = System.err; - private static int ALL = -1; + //private static int ALL = -1; private java.util.Stack stack = new java.util.Stack(); private static String[] tokenNames; private final static int ROOT_ID = 0; diff --git a/app/src/processing/app/preproc/PdePreprocessor.java b/app/src/processing/app/preproc/PdePreprocessor.java index 8eebaaac4..fe9ca2fa1 100644 --- a/app/src/processing/app/preproc/PdePreprocessor.java +++ b/app/src/processing/app/preproc/PdePreprocessor.java @@ -34,7 +34,7 @@ import java.io.*; import antlr.*; import antlr.collections.*; -import antlr.collections.impl.*; +//import antlr.collections.impl.*; import com.oroinc.text.regex.*; diff --git a/build/macosx/make.sh b/build/macosx/make.sh index 0186dc79f..c63294bf7 100755 --- a/build/macosx/make.sh +++ b/build/macosx/make.sh @@ -117,7 +117,8 @@ echo Building the PDE... # compile the code as java 1.3, so that the application will run and # show the user an error, rather than crapping out with some strange # "class not found" crap -../build/macosx/work/jikes -target 1.3 +D -classpath ../build/macosx/work/classes:../build/macosx/work/lib/core.jar:../build/macosx/work/lib/antlr.jar:../build/macosx/work/lib/oro.jar:../build/macosx/work/lib/registry.jar:$CLASSPATH -d ../build/macosx/work/classes *.java syntax/*.java preproc/*.java tools/*.java +../build/macosx/work/jikes -target 1.3 +D -classpath ../build/macosx/work/classes:../build/macosx/work/lib/core.jar:../build/macosx/work/lib/antlr.jar:../build/macosx/work/lib/oro.jar:../build/macosx/work/lib/registry.jar:$CLASSPATH -d ../build/macosx/work/classes src/processing/app/*.java src/processing/app/syntax/*.java src/processing/app/preproc/*.java src/processing/app/tools/*.java src/antlr/*.java src/antlr/java/*.java +#../build/macosx/work/jikes -target 1.3 +D -classpath ../build/macosx/work/classes:../build/macosx/work/lib/core.jar:../build/macosx/work/lib/antlr.jar:../build/macosx/work/lib/oro.jar:../build/macosx/work/lib/registry.jar:$CLASSPATH -d ../build/macosx/work/classes *.java syntax/*.java preproc/*.java tools/*.java #javac -source 1.3 -target 1.3 -classpath ../build/macosx/work/classes:../build/macosx/work/lib/core.jar:../build/macosx/work/lib/antlr.jar:../build/macosx/work/lib/oro.jar:../build/macosx/work/lib/registry.jar:$CLASSPATH -d ../build/macosx/work/classes *.java syntax/*.java preproc/*.java tools/*.java # version that follows includes jalopy.jar and log4j.jar #../build/macosx/work/jikes -target 1.3 +D -classpath ../build/macosx/work/classes:../build/macosx/work/lib/core.jar:../build/macosx/work/lib/antlr.jar:../build/macosx/work/lib/oro.jar:../build/macosx/work/lib/registry.jar:../build/macosx/work/lib/jalopy.jar:../build/macosx/work/lib/log4j.jar:$CLASSPATH -d ../build/macosx/work/classes tools/*.java preproc/*.java syntax/*.java *.java