From 53fa60c6d949178d8a0d6ed324f1e7fbb4ea85d0 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 10 Oct 2004 01:30:42 +0000 Subject: [PATCH] fixes for several small "save as" bugs --- app/PdeSketch.java | 25 ++++++++++++++++++++++++- todo.txt | 11 +++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/PdeSketch.java b/app/PdeSketch.java index 428f7616b..fbd5d6b20 100644 --- a/app/PdeSketch.java +++ b/app/PdeSketch.java @@ -585,7 +585,11 @@ public class PdeSketch { "Save sketch folder as...", FileDialog.SAVE); // always default to the sketchbook folder.. - fd.setDirectory(PdePreferences.get("sketchbook.path")); + //fd.setDirectory(PdePreferences.get("sketchbook.path")); + fd.setDirectory(folder.getParent()); + fd.setFile(folder.getName()); + //System.out.println("setting to " + folder.getParent()); + // TODO or maybe this should default to the // parent dir of the old folder? @@ -608,6 +612,22 @@ public class PdeSketch { return false; } + // check to see if the user is trying to save this sketch + // inside the same sketch + try { + String newPath = newFolder.getCanonicalPath() + File.separator; + String oldPath = folder.getCanonicalPath() + File.separator; + //System.out.println(newPath); + //System.out.println(oldPath); + + if (newPath.indexOf(oldPath) == 0) { + PdeBase.showWarning("How very Borges of you", + "You cannot save the sketch into a folder\n" + + "inside itself. This would go on forever.", null); + return false; + } + } catch (IOException e) { } + // copy the entire contents of the sketch folder PdeBase.copyDir(folder, newFolder); @@ -651,6 +671,9 @@ public class PdeSketch { //sketchbook.rebuildMenu(); // done inside PdeEditor instead + // update the tabs for the name change + editor.header.repaint(); + // let PdeEditor know that the save was successful return true; } diff --git a/todo.txt b/todo.txt index 8771011df..9a356771f 100644 --- a/todo.txt +++ b/todo.txt @@ -23,12 +23,11 @@ X not really separate files, so that could be trouble. X add file of a .pde or .java file should update the tabs bar X and prolly not really complain if it's in the same folder X dim "rename" when the main tab is selected (since user needs to "save as") - -saving issues -_ "save as" not properly updating the tab header -_ also include the name of the previous sketch for "save as" -_ prevent folks from saving a sketch inside its own folder -_ will cause bizarro recursive folder action +X "save ass" issues +X "save as" not properly updating the tab header +X also include the name of the previous sketch for "save as" +X prevent folks from saving a sketch inside its own folder +X will cause bizarro recursive folder action _ allow to use doubles on casting -- particularly for Math.cos() et al