diff --git a/processing/app/PdeEditorHeader.java b/processing/app/PdeEditorHeader.java index 320a8d270..c0dd7b3e5 100644 --- a/processing/app/PdeEditorHeader.java +++ b/processing/app/PdeEditorHeader.java @@ -46,7 +46,7 @@ public class PdeEditorHeader extends JComponent { JMenu menu; JPopupMenu popup; - JMenuItem renameItem; + JMenuItem deleteItem; int menuLeft; int menuRight; @@ -169,7 +169,8 @@ public class PdeEditorHeader extends JComponent { } // disable rename on the first tab - renameItem.setEnabled(sketch.current != sketch.code[0]); + deleteItem.setEnabled(sketch.current != sketch.code[0]); + // re-enabling for 75 to bring back renaming of sketches //int x = 0; //PdePreferences.GUI_SMALL; int x = (PdeBase.platform == PdeBase.MACOSX) ? 0 : 1; @@ -299,7 +300,6 @@ public class PdeEditorHeader extends JComponent { } }); menu.add(item); - renameItem = item; item = new JMenuItem("Delete"); item.addActionListener(new ActionListener() { @@ -308,6 +308,7 @@ public class PdeEditorHeader extends JComponent { } }); menu.add(item); + deleteItem = item; item = new JMenuItem("Hide"); item.addActionListener(new ActionListener() { diff --git a/processing/app/PdeSketch.java b/processing/app/PdeSketch.java index 288c2cc11..a70089ac6 100644 --- a/processing/app/PdeSketch.java +++ b/processing/app/PdeSketch.java @@ -117,14 +117,6 @@ public class PdeSketch { folder = new File(new File(path).getParent()); //System.out.println("sketch dir is " + folder); - codeFolder = new File(folder, "code"); - dataFolder = new File(folder, "data"); - - File libraryFolder = new File(folder, "library"); - if (libraryFolder.exists()) { - library = true; - } - load(); } @@ -137,10 +129,21 @@ public class PdeSketch { * a nightmare to keep track of what files went where, because * not all the data will be saved to disk. * - * The exception is when an external editor is in use, + * This also gets called when the main sketch file is renamed, + * because the sketch has to be reloaded from a different folder. + * + * Another exception is when an external editor is in use, * in which case the load happens each time "run" is hit. */ public void load() { + codeFolder = new File(folder, "code"); + dataFolder = new File(folder, "data"); + + File libraryFolder = new File(folder, "library"); + if (libraryFolder.exists()) { + library = true; + } + // get list of files in the sketch folder String list[] = folder.list(); @@ -269,7 +272,7 @@ public class PdeSketch { public void renameCode() { // don't allow rename of the main code - if (current == code[0]) return; + //if (current == code[0]) return; // TODO maybe gray out the menu on setCurrent(0) // ask for new name of file (internal to window) @@ -298,6 +301,11 @@ public class PdeSketch { return; } + if (newName.trim().equals("")) { + // don't allow blank names + return; + } + String newFilename = null; int newFlavor = 0; @@ -308,6 +316,14 @@ public class PdeSketch { newFlavor = PDE; } else if (newName.endsWith(".java")) { + if (code[0] == current) { + PdeBase.showWarning("Problem with rename", + "The main .pde file cannot be .java file.\n" + + "(It may be time for your to graduate to a\n" + + "\"real\" programming environment)", null); + return; + } + newFilename = newName; newName = newName.substring(0, newName.length() - 5); newFlavor = JAVA; @@ -341,9 +357,20 @@ public class PdeSketch { "\" to \"" + newFile.getName() + "\"", null); return; } - current.file = newFile; - current.name = newName; - current.flavor = newFlavor; + + if (current == code[0]) { + // if renaming the main class, now rename the folder and re-open + File newFolder = new File(folder.getParentFile(), newName); + boolean success = folder.renameTo(newFolder); + folder = newFolder; + load(); + + } else { + // just reopen the class itself + current.file = newFile; + current.name = newName; + current.flavor = newFlavor; + } } else { // creating a new file try { @@ -591,10 +618,14 @@ public class PdeSketch { FileDialog fd = new FileDialog(editor, //new Frame(), "Save sketch folder as...", FileDialog.SAVE); - // always default to the sketchbook folder.. - //fd.setDirectory(PdePreferences.get("sketchbook.path")); - fd.setDirectory(folder.getParent()); + if (isReadOnly()) { + // default to the sketchbook folder + fd.setDirectory(PdePreferences.get("sketchbook.path")); + } else { + fd.setDirectory(folder.getParent()); + } fd.setFile(folder.getName()); + //System.out.println("setting to " + folder.getParent()); // TODO or maybe this should default to the diff --git a/processing/todo.txt b/processing/todo.txt index e938f03ac..4d561b2fa 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -30,6 +30,9 @@ o if additional tab is "public" class.. then make external? X this seems too dangerous X make font builder vertically resizable X 200 pt font hoses things / hides buttons +X bring back "rename" ? +X rename is now enabled on the first tab +X 'delete' is disabled on the first tab (what would you do after delete?) sketchbook/prefs location X read from registry key to get the proper name for these folders @@ -93,6 +96,8 @@ X focusGained/focusLost was added.. o if a data file is in the sketch (not data) folder export breaks o works fine in the editor, but on export gets a nullpointer ex X no way around this, because needs to be able to read from local dir +X if saving a read-only sketch, default to sketchbook folder +X (before was prompting to save inside the same folder.. annoying) building libraries - not gonna build libs in p5 ide for 1.0 o compiling - main file is a .java not a .pde @@ -197,7 +202,6 @@ _ set both versions to require java 1.4 _ change the Info.plist inside macosx _ and add something to PdeBase to make sure that it's in 1.4 -_ bring back "rename" ? _ may need a progress bar for "save as" _ or just the file copy function in general _ since it may take a long time (i.e. 1000s of screen grabs) @@ -226,6 +230,9 @@ _ mouse wheel broken in the text editor? (windows jdk 1.5?) _ implement horizontal version of PdeEditorButtons _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1076707944 +_ transparently convert spaces to underscores +_ underscoring everything is kinda nasty + ......................................................................