From 53bb933a61e2903f266fb392217039e76fba21a5 Mon Sep 17 00:00:00 2001 From: benfry Date: Mon, 10 Nov 2003 20:57:11 +0000 Subject: [PATCH] clearing up preferences, attempting compilation --- processing/app/PdeEditor.java | 2 +- processing/app/PdeHistory.java | 6 +++-- processing/app/PdePreferences.java | 36 ++++++++++++++++++++---------- processing/app/PdeSketchbook.java | 15 +++++++++---- processing/todo.txt | 2 ++ 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index b67938cf0..e630eb2d8 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -2501,7 +2501,7 @@ public class PdeEditor extends JFrame cutItem.setEnabled(true); copyItem.setEnabled(true); - referenceFile = PdeKeywords.get(parent.getSelectedText()); + referenceFile = PdeKeywords.getReference(parent.getSelectedText()); if (referenceFile != null) { referenceItem.setEnabled(true); } diff --git a/processing/app/PdeHistory.java b/processing/app/PdeHistory.java index 611369cc1..2611d8784 100644 --- a/processing/app/PdeHistory.java +++ b/processing/app/PdeHistory.java @@ -187,7 +187,8 @@ public class PdeHistory { if (noPreviousHistory) { // to get add the actual menu, to get the 'clear' item in there - rebuildMenu(historyFile.getPath()); + //rebuildMenu(historyFile.getPath()); + rebuildMenu(); } } catch (IOException e) { @@ -287,7 +288,8 @@ public class PdeHistory { PdeBase.showWarning("History Problem", "Could not erase history", null); } - rebuildMenu(historyFile.getPath()); + rebuildMenu(); + //PdeHistory.this.rebuildMenu(historyFile.getPath()); } }); menu.add(item); diff --git a/processing/app/PdePreferences.java b/processing/app/PdePreferences.java index 20d823afc..aaa691302 100644 --- a/processing/app/PdePreferences.java +++ b/processing/app/PdePreferences.java @@ -127,8 +127,8 @@ public class PdePreferences extends JComponent { */ } catch (Exception e) { - showError(null, "Could not read default settings.\n" + - "You'll need to reinstall Processing.", e); + PdeBase.showError(null, "Could not read default settings.\n" + + "You'll need to reinstall Processing.", e); System.exit(1); //System.err.println("Error reading default settings"); //e.printStackTrace(); @@ -140,7 +140,7 @@ public class PdePreferences extends JComponent { String platformExtension = "." + PdeBase.platforms[PdeBase.platform]; int extensionLength = platformExtension.length(); - Enumeration e = properties.propertyNames(); + Enumeration e = table.keys(); //properties.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); if (key.endsWith(platformExtension)) { @@ -150,7 +150,7 @@ public class PdePreferences extends JComponent { System.out.println("found platform specific prop \"" + actualKey + "\" \"" + value + "\""); - properties.put(actualKey, value); + table.put(actualKey, value); System.out.println("now set to " + table.get(actualKey)); } } @@ -428,10 +428,10 @@ public class PdePreferences extends JComponent { FileOutputStream output = new FileOutputStream(preferencesFile); PrintWriter writer = new PrintWriter(new OutputStreamWriter(output)); - Enumeration enum = properties.propertyNames(); + Enumeration enum = table.keys(); //properties.propertyNames(); while (enum.hasMoreElements()) { String key = (String) e.nextElement(); - writer.println(key + "=" + properties.get(key)); + writer.println(key + "=" + ((String) table.get(key))); } writer.flush(); @@ -516,24 +516,27 @@ public class PdePreferences extends JComponent { //} static public String get(String attribute /*, String defaultValue */) { + return (String) table.get(attribute); + /* //String value = (properties != null) ? //properties.getProperty(attribute) : applet.getParameter(attribute); String value = properties.getProperty(attribute); return (value == null) ? defaultValue : value; + */ } static public void set(String attribute, String value) { - preferences.put(attribute, value); + //preferences.put(attribute, value); + table.put(attribute, value); } - static public boolean getBoolean(String attribute /*, boolean defaultValue*/) { + static public boolean getBoolean(String attribute) { String value = get(attribute, null); - return (value == null) ? defaultValue : - (new Boolean(value)).booleanValue(); + return (new Boolean(value)).booleanValue(); /* supposedly not needed, because anything besides 'true' @@ -556,6 +559,9 @@ public class PdePreferences extends JComponent { static public int getInteger(String attribute /*, int defaultValue*/) { + return Integer.parseInt(get(attribute)); + + /* String value = get(attribute, null); if (value == null) return defaultValue; @@ -569,6 +575,7 @@ public class PdePreferences extends JComponent { //if (value == null) return defaultValue; //return (value == null) ? defaultValue : //Integer.parseInt(value); + */ } @@ -592,10 +599,15 @@ public class PdePreferences extends JComponent { } + static public Color setColor(String attr, Color what) { + + } + + static public Font getFont(String which /*, Font otherwise*/) { //System.out.println("getting font '" + which + "'"); String str = get(which); - if (str == null) return otherwise; // ENABLE LATER + //if (str == null) return otherwise; // ENABLE LATER StringTokenizer st = new StringTokenizer(str, ","); String fontname = st.nextToken(); String fontstyle = st.nextToken(); @@ -607,7 +619,7 @@ public class PdePreferences extends JComponent { static public SyntaxStyle getStyle(String what /*, String dflt*/) { - String str = get("editor.program." + what + ".style", dflt); + String str = get("editor.program." + what + ".style"); //, dflt); StringTokenizer st = new StringTokenizer(str, ","); diff --git a/processing/app/PdeSketchbook.java b/processing/app/PdeSketchbook.java index 3b58a1f7d..87d32f8ab 100644 --- a/processing/app/PdeSketchbook.java +++ b/processing/app/PdeSketchbook.java @@ -87,6 +87,10 @@ public class PdeSketchbook { sketchbookFolder.mkdirs(); } + addSketches(sketchbookFolder); + + // TODO add examples folder here too + /* // files for the current user (for now, most likely 'default') @@ -129,6 +133,8 @@ public class PdeSketchbook { } menu.addSeparator(); */ + + /* if (addSketches(menu, userFolder, false)) { menu.addSeparator(); } @@ -137,6 +143,7 @@ public class PdeSketchbook { item.setEnabled(false); menu.add(item); } + */ /* // doesn't seem that refresh is worthy of its own menu item @@ -154,8 +161,8 @@ public class PdeSketchbook { } - protected boolean addSketches(Menu menu, File folder, - /*boolean allowUser,*/ boolean root) + protected boolean addSketches(Menu menu, File folder) { + // /*boolean allowUser,*/ boolean root) throws IOException { // skip .DS_Store files, etc if (!folder.isDirectory()) return false; @@ -167,7 +174,7 @@ public class PdeSketchbook { boolean ifound = false; for (int i = 0; i < list.length; i++) { - if (list[i].equals(editor.userName) && root) continue; + //if (list[i].equals(editor.userName) && root) continue; if (list[i].equals(".") || list[i].equals("..") || @@ -184,7 +191,7 @@ public class PdeSketchbook { Menu submenu = new Menu(list[i]); // needs to be separate var // otherwise would set ifound to false - boolean found = addSketches(submenu, subfolder, false); + boolean found = addSketches(submenu, subfolder); //, false); if (found) { menu.add(submenu); ifound = true; diff --git a/processing/todo.txt b/processing/todo.txt index 523334efe..ee0070f1a 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -2,6 +2,8 @@ X ifdef JDK14 around a piece of 1.4 specific window code X use mozilla for opening urls in linux, switched to more compatible exec() +_ add examples stuff + _ "add library" menu item and submenu _ iterate through the 'library' folders _ eliminate the requirement for a 'data' folder