From 515b0adb7630964b4a586ad3c3c6619d4fdec0fd Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 11 Nov 2003 22:52:52 +0000 Subject: [PATCH] things actually semi-running once again --- processing/app/PdeBase.java | 80 ++++------------------------------ processing/app/PdeEditor.java | 34 +++++++-------- processing/app/PdeHistory.java | 3 +- 3 files changed, 28 insertions(+), 89 deletions(-) diff --git a/processing/app/PdeBase.java b/processing/app/PdeBase.java index 43453696a..fa3448feb 100644 --- a/processing/app/PdeBase.java +++ b/processing/app/PdeBase.java @@ -45,27 +45,11 @@ import com.apple.mrj.*; * general interaction with the system (launching URLs, loading * files and images, etc) that comes from that. */ -public class PdeBase /*extends JFrame implements ActionListener*/ -{ +public class PdeBase { static final String VERSION = "0068 Alpha"; - //static Frame frame; // now 'this' - //static String encoding; - //static Image icon; - - // indicator that this is the first time this feller has used p5 - //static boolean firstTime; - - //boolean errorState; PdeEditor editor; - //WindowAdapter windowListener; - - //Menu renderMenu; - //CheckboxMenuItem normalItem, openglItem; - //MenuItem illustratorItem; - - // the platforms static final int WINDOWS = 1; static final int MACOS9 = 2; static final int MACOSX = 3; @@ -79,7 +63,6 @@ public class PdeBase /*extends JFrame implements ActionListener*/ static public void main(String args[]) { - //System.getProperties().list(System.out); PdeBase app = new PdeBase(); } @@ -112,11 +95,6 @@ public class PdeBase /*extends JFrame implements ActionListener*/ } - // build the editor object - - editor = new PdeEditor(); - - // set the look and feel before opening the window try { @@ -133,56 +111,17 @@ public class PdeBase /*extends JFrame implements ActionListener*/ } - // load in preferences (last sketch used, window placement, etc) - - //preferences = new PdePreferences(); - - - // read in the keywords for the reference - - //final String KEYWORDS = "pde_keywords.properties"; - /* - keywords = new Properties(); - - try { - keywords.load(PdeBase.getStream("pde_keywords.properties")); - - } catch (Exception e) { - String message = - "An error occurred while loading the keywords,\n" + - "\"Find in reference\" will not be available."; - JOptionPane.showMessageDialog(editor, message, - "Problem loading keywords", - JOptionPane.WARNING_MESSAGE); - - System.err.println(e.toString()); - e.printStackTrace(); - } - */ + // build the editor object + editor = new PdeEditor(); // get things rawkin - - //editor.restorePreferences(); // done at end of constructor editor.pack(); + + // has to be here to set window size properly + editor.restorePreferences(); + + // show the window editor.show(); - - - //editor = new PdeEditor(this); - //getContentPane().setLayout(new BorderLayout()); - //getContentPane().add("Center", editor); - - - // load preferences and finish up - - // handle layout - //this.pack(); // maybe this should be before the setBounds call - // do window placement before loading sketch stuff - //restorePreferences(); - - // now that everything is set up, open last-used sketch, etc. - //editor.restorePreferences(); - - //show(); } @@ -378,7 +317,7 @@ public class PdeBase /*extends JFrame implements ActionListener*/ } - static public InputStream getStream(/*Class cls,*/ String filename) + static public InputStream getStream(String filename) throws IOException { if ((PdeBase.platform == PdeBase.MACOSX) || (PdeBase.platform == PdeBase.MACOS9)) { @@ -387,7 +326,6 @@ public class PdeBase /*extends JFrame implements ActionListener*/ // actually, this is only the case when running as a .app, // since it works fine from run.sh, but not Processing.app return new FileInputStream("lib/" + filename); - } // all other, more reasonable operating systems diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index fb948b294..d2f3bcbd5 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -199,7 +199,8 @@ public class PdeEditor extends JFrame pain.add("West", leftPanel); */ - pain.add("West", new PdeEditorButtons(this)); + buttons = new PdeEditorButtons(this); + pain.add("West", buttons); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BorderLayout()); @@ -341,7 +342,7 @@ public class PdeEditor extends JFrame }); // can this happen here? - restorePreferences(); + //restorePreferences(); } @@ -380,6 +381,7 @@ public class PdeEditor extends JFrame } if (windowPositionInvalid) { + System.out.println("using default size"); int windowH = PdePreferences.getInteger("default.window.height"); int windowW = PdePreferences.getInteger("default.window.width"); setBounds((screen.width - windowW) / 2, @@ -408,6 +410,8 @@ public class PdeEditor extends JFrame } else { skNew(); } + } else { + skNew(); } @@ -504,8 +508,6 @@ public class PdeEditor extends JFrame }); menu.add(item); - //sketchbookMenu = new JMenu("Open"); - //menu.add(sketchbookMenu); menu.add(sketchbook.rebuildMenu()); saveMenuItem = newMenuItem("Save", 'S'); @@ -532,8 +534,6 @@ public class PdeEditor extends JFrame }); menu.add(item); - //menu.addSeparator(); - exportMenu = buildExportMenu(); menu.add(exportMenu); @@ -547,10 +547,10 @@ public class PdeEditor extends JFrame item.setEnabled(false); menu.add(item); - menu.addSeparator(); - // macosx already has its own preferences and quit menu if (PdeBase.platform != PdeBase.MACOSX) { + menu.addSeparator(); + item = new JMenuItem("Preferences"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -569,8 +569,6 @@ public class PdeEditor extends JFrame }); menu.add(item); } - //menu.addActionListener(this); - //menubar.add(menu); return menu; } @@ -693,7 +691,7 @@ public class PdeEditor extends JFrame }); menu.add(item); - item = new JMenuItem("Proce55ing.net", '5'); + item = newMenuItem("Proce55ing.net", '5'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PdeBase.openURL("http://Proce55ing.net/"); @@ -1326,8 +1324,10 @@ public class PdeEditor extends JFrame if (watcher != null) watcher.stop(); //System.out.println("stop2"); message(EMPTY); - //System.out.println("stop3"); - buttons.clear(); + + // the buttons are still null during the constructor + /*if (buttons != null)*/ buttons.clear(); + //System.out.println("stop4"); running = false; //System.out.println("NOT RUNNING"); @@ -1473,7 +1473,7 @@ public class PdeEditor extends JFrame switch (checking) { case SK_NEW: skNew2(); break; case SK_OPEN: skOpen2(openingPath, openingName); break; - case DO_OPEN: doOpen2(); break; + //case DO_OPEN: doOpen2(); break; case DO_QUIT: doQuit2(); break; } checking = 0; @@ -1575,6 +1575,7 @@ public class PdeEditor extends JFrame } + /* public void doOpen() { checkModified(DO_OPEN); } @@ -1599,6 +1600,7 @@ public class PdeEditor extends JFrame handleOpen(filename, new File(directory, filename), null); } + */ protected void handleOpen(String isketchName, @@ -2384,7 +2386,7 @@ public class PdeEditor extends JFrame /** - * Cleanup temp files + * Cleanup temporary files */ protected void cleanTempFiles() { if (tempBuildPath == null) return; @@ -2450,8 +2452,6 @@ public class PdeEditor extends JFrame } }); this.add(item); - - //this.addSeparator(); item = new JMenuItem("Select All"); item.addActionListener(new ActionListener() { diff --git a/processing/app/PdeHistory.java b/processing/app/PdeHistory.java index 2611d8784..6be50ec7a 100644 --- a/processing/app/PdeHistory.java +++ b/processing/app/PdeHistory.java @@ -69,6 +69,8 @@ public class PdeHistory { public PdeHistory(PdeEditor editor) { this.editor = editor; + menu = new JMenu("History"); + menuListener = new ActionListener() { public void actionPerformed(ActionEvent e) { retrieve(e.getActionCommand()); @@ -87,7 +89,6 @@ public class PdeHistory { public void attachMenu(JMenu parent) { //if (PdePreferences.getBoolean("history.recording")) { - menu = new JMenu("History"); parent.add(menu); // should leave enabled, since can still get old history