diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 510b7afac..7a78a7864 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -67,11 +67,11 @@ public class Sketch { private SketchCode current; private int currentIndex; - /** + /** * Number of sketchCode objects (tabs) in the current sketch. Note that this - * will be the same as code.length, because the getCode() method returns + * will be the same as code.length, because the getCode() method returns * just the code[] array, rather than a copy of it, or an array that's been - * resized to just the relevant files themselves. + * resized to just the relevant files themselves. * http://dev.processing.org/bugs/show_bug.cgi?id=940 */ private int codeCount; @@ -719,7 +719,7 @@ public class Sketch { fd.setDirectory(folder.getParent()); } fd.setFile(folder.getName()); - + fd.setVisible(true); newParentDir = fd.getDirectory(); newName = fd.getFile(); @@ -945,6 +945,19 @@ public class Sketch { } } + // If it's a replacement, delete the old file first, + // otherwise case changes will not be preserved. + // http://dev.processing.org/bugs/show_bug.cgi?id=969 + if (replacement) { + boolean muchSuccess = destFile.delete(); + if (!muchSuccess) { + Base.showWarning("Error adding file", + "Could not delete the existing '" + + filename + "' file.", null); + return false; + } + } + // make sure they aren't the same file if ((codeExtension == null) && sourceFile.equals(destFile)) { Base.showWarning("You can't fool me", @@ -1052,7 +1065,7 @@ public class Sketch { current = code[which]; currentIndex = which; - + editor.setCode(current); editor.header.rebuild(); } @@ -1696,7 +1709,7 @@ public class Sketch { } } - File bagelJar = Base.isMacOS() ? + File bagelJar = Base.isMacOS() ? Base.getContentFile("core.jar") : Base.getContentFile("lib/core.jar"); if (separateJar) { @@ -1999,9 +2012,9 @@ public class Sketch { File jarFolder = new File(destFolder, "lib"); - + /// where all the skeleton info lives - + File skeletonFolder = new File(Base.getContentFile("lib"), "export"); /// on macosx, need to copy .app skeleton since that's @@ -2135,7 +2148,7 @@ public class Sketch { /// add core.jar to the jar destination folder - File bagelJar = Base.isMacOS() ? + File bagelJar = Base.isMacOS() ? Base.getContentFile("core.jar") : Base.getContentFile("lib/core.jar"); Base.copyFile(bagelJar, new File(jarFolder, "core.jar")); @@ -2775,7 +2788,7 @@ public class Sketch { String newName = sanitizeName(origName); if (!newName.equals(origName)) { - String msg = + String msg = "The sketch name had to be modified. Sketch names can only consist\n" + "of ASCII characters and numbers, and cannot start with a number.\n" + "They should also be less less than 64 characters long)\n"; diff --git a/todo.txt b/todo.txt index 3ac3c053f..bb270676c 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,11 @@ 0153 pde +X delete files before adding, otherwise case changes are not preserved +X http://dev.processing.org/bugs/show_bug.cgi?id=969 +previous +o put the "had to rename sketch" message in the msg bar +o it's ugly/annoying/intrusive +X just print it to the console _ don't open more than one "create font" or "color selector" _ http://dev.processing.org/bugs/show_bug.cgi?id=830 @@ -563,6 +569,13 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=281 PDE / Editor +_ should really be doing the 'right' thing with sketch file handling +_ create temporary file when saving +_ once done writing, use remove the original and rename the old +_ some basic stuff like this.. +_ http://dev.processing.org/bugs/show_bug.cgi?id=968 +_ when disk is full, Processing zeroes files when it tries to save changes +_ http://dev.processing.org/bugs/show_bug.cgi?id=967 _ sketch marked as modified too aggressively _ http://dev.processing.org/bugs/show_bug.cgi?id=328 _ Closing the last window doesn't cause PDE to save its position/contents/etc @@ -586,6 +599,7 @@ _ but the window is not properly set as untitled _ http://dev.processing.org/bugs/show_bug.cgi?id=700 _ strange NullPointerException problem prevents launch _ some kind of NPE in handleOpenInternal and friends +_ appears to be a synchronization problem with the loading _ when opening from double-click on the mac, doesn't replace untitled _ or in general, issues between opening new window and another launching _ probably need to synchronize the file open methods inside Base @@ -606,8 +620,6 @@ _ the contents in the files are not the same, but the main-tab is _ showing the contents of the .java tab, so if you press save _ you will overwrite your original code from the main-tab. _ after fixing name of sketch, ensure sketch of that name does not exist -_ put the "had to rename sketch" message in the msg bar -_ it's ugly/annoying/intrusive _ do quick fix for tab bar _ don't show tabs when there are too many _ maybe move the list of files to the top? @@ -621,10 +633,6 @@ _ add auto-save to the editor _ http://dev.processing.org/bugs/show_bug.cgi?id=739 _ dragging title bar while sketch running causes strange selection behavior _ http://dev.processing.org/bugs/show_bug.cgi?id=504 -_ should really be doing the 'right' thing with sketch file handling -_ create temporary file when saving -_ once done writing, use remove the original and rename the old -_ some basic stuff like this.. _ shortcuts not working after rename? (osx only?) _ http://dev.processing.org/bugs/show_bug.cgi?id=505 _ convert tabs to spaces when pasting text