mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
finish up fixes for #424 by clarifying delete sketch msg and moving to trash
This commit is contained in:
@@ -399,7 +399,7 @@ public class Platform {
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to move to the Trash on OS X, or the Recycle Bin on Windows.
|
||||
* Attempts to move to the Trash on macOS, or the Recycle Bin on Windows.
|
||||
* Also tries to find a suitable Trash location on Linux.
|
||||
* If not possible, just deletes the file or folder instead.
|
||||
* @param file the folder or file to be removed/deleted
|
||||
|
||||
@@ -57,8 +57,8 @@ public class Sketch {
|
||||
private File mainFile;
|
||||
|
||||
/**
|
||||
* Name of sketch, which is the name of main file
|
||||
* (without .pde or .java extension)
|
||||
* Name of the sketch, which is the name of the folder since 4.0 beta 6.
|
||||
* Prior, it was the "pretty" name of the first tab (they were synonymous).
|
||||
*/
|
||||
private String name;
|
||||
|
||||
@@ -664,8 +664,8 @@ public class Sketch {
|
||||
// confirm deletion with user, yes/no
|
||||
Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
|
||||
String prompt = (currentIndex == 0) ?
|
||||
Language.text("warn.delete.sketch") :
|
||||
Language.interpolate("warn.delete.file", current.getPrettyName());
|
||||
Language.interpolate("warn.delete.sketch_folder", getName()) :
|
||||
Language.interpolate("warn.delete.sketch_file", current.getPrettyName());
|
||||
int result = JOptionPane.showOptionDialog(editor,
|
||||
prompt,
|
||||
Language.text("warn.delete"),
|
||||
@@ -675,24 +675,22 @@ public class Sketch {
|
||||
options,
|
||||
options[0]);
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
if (currentIndex == 0) {
|
||||
if (currentIndex == 0) { // delete the entire sketch
|
||||
// need to unset all the modified flags, otherwise tries
|
||||
// to do a save on the handleNew()
|
||||
|
||||
// delete the entire sketch
|
||||
Util.removeDir(folder);
|
||||
|
||||
// get the changes into the sketchbook menu
|
||||
//sketchbook.rebuildMenus();
|
||||
// Attempt to move to the trash (falls back to removeDir)
|
||||
try {
|
||||
Platform.deleteFile(folder);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// make a new sketch and rebuild the sketch menu
|
||||
//editor.handleNewUnchecked();
|
||||
//editor.handleClose2();
|
||||
editor.getBase().rebuildSketchbook();
|
||||
editor.getBase().handleClose(editor, false);
|
||||
|
||||
} else {
|
||||
// delete the file
|
||||
} else { // delete a single tab
|
||||
if (!current.deleteFile()) {
|
||||
Messages.showMessage(Language.text("delete.messages.cannot_delete.file"),
|
||||
Language.text("delete.messages.cannot_delete.file.description")+" \"" +
|
||||
|
||||
@@ -312,7 +312,7 @@ public class Util {
|
||||
|
||||
/**
|
||||
* Remove all files in a directory and the directory itself.
|
||||
* Optinally prints error messages with failed filenames.
|
||||
* Optionally, prints error messages with failed filenames.
|
||||
* Does not follow symlinks.
|
||||
*/
|
||||
static public boolean removeDir(File dir, boolean printErrorMessages) {
|
||||
|
||||
@@ -589,8 +589,8 @@ contrib.import.errors.link = Error: The library %s has a strange looking downloa
|
||||
# Warnings
|
||||
|
||||
warn.delete = Delete
|
||||
warn.delete.sketch = Are you sure you want to delete this sketch?
|
||||
warn.delete.file = Are you sure you want to delete "%s"?
|
||||
warn.delete.sketch_folder = Are you sure you want to delete this sketch?\nThis will remove the entire "%s" folder.
|
||||
warn.delete.sketch_file = Are you sure you want to delete "%s"?
|
||||
warn.cannot_change_mode.title = Cannot change mode
|
||||
warn.cannot_change_mode.body = Cannot change mode,\nbecause "%s" mode is not compatible with current mode.
|
||||
|
||||
|
||||
@@ -3,18 +3,28 @@ X Bring back getMainProgram() for Python Mode
|
||||
X https://github.com/processing/processing4/issues/409
|
||||
X You must first install tweak Mode to use this sketch
|
||||
X https://github.com/processing/processing4/issues/415
|
||||
_ test with Python Mode before release
|
||||
|
||||
sketchbook/open/deletions
|
||||
X test "obvious" sketch folder (and whether it prompts)
|
||||
X opening Downloads > something.pde made a p5.js sketch with only an index.html
|
||||
X if no sketch.properties, reset nextMode to the default mode
|
||||
X deleting sketch removed contents of Download folder
|
||||
X https://github.com/processing/processing4/issues/424
|
||||
X also very problematic for what happens with Save As
|
||||
X ah, this is because it was just a single .pde file, yikes
|
||||
X sketch.properties should be present, but won't be if the parent is renamed
|
||||
o always write sketch.properties? (would help the later rename case)
|
||||
X when loading, prompt to ask whether the parent folder is the sketch folder?
|
||||
X if it is, write sketch.properties to set the main file
|
||||
X if not, move it to its own folder "move blah.pde to a folder named blah"
|
||||
X are you sure you want to delete the sketch "Downloads"
|
||||
X instead of "are you sure you want to delete this sketch?"
|
||||
X have 'delete' function move things to the trash
|
||||
o or remove 'delete' as an option altogether
|
||||
X new language string: warn.delete.sketch_folder so we can include folder name
|
||||
X and renamed warn.delete.file to warn.delete.sketch_file
|
||||
|
||||
_ deleting sketch removed contents of Download folder
|
||||
_ https://github.com/processing/processing4/issues/424
|
||||
_ at a minimum, need to have 'delete' function move things to the trash
|
||||
_ or remove 'delete' as an option altogether
|
||||
_ also very problematic for what happens with Save As
|
||||
_ ah, this is because it was just a single .pde file, yikes
|
||||
_ sketch.properties should be present, but won't be if the parent is renamed
|
||||
_ always write sketch.properties? (would help the later rename case)
|
||||
_ when loading, prompt to ask whether the parent folder is the sketch folder?
|
||||
_ if it is, write sketch.properties to set the main file
|
||||
_ if not, move it to its own folder "move blah.pde to a folder named blah"
|
||||
|
||||
_ examples handling is less than ideal
|
||||
_ examples not mentioned in warning dialog when installing
|
||||
|
||||
Reference in New Issue
Block a user