Skip to content

Commit f6ff01e

Browse files
committed
finish up fixes for #424 by clarifying delete sketch msg and moving to trash
1 parent 1eefbe0 commit f6ff01e

File tree

5 files changed

+37
-29
lines changed

5 files changed

+37
-29
lines changed

app/src/processing/app/Platform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static public String getJavaPath() {
399399

400400

401401
/**
402-
* Attempts to move to the Trash on OS X, or the Recycle Bin on Windows.
402+
* Attempts to move to the Trash on macOS, or the Recycle Bin on Windows.
403403
* Also tries to find a suitable Trash location on Linux.
404404
* If not possible, just deletes the file or folder instead.
405405
* @param file the folder or file to be removed/deleted

app/src/processing/app/Sketch.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public class Sketch {
5757
private File mainFile;
5858

5959
/**
60-
* Name of sketch, which is the name of main file
61-
* (without .pde or .java extension)
60+
* Name of the sketch, which is the name of the folder since 4.0 beta 6.
61+
* Prior, it was the "pretty" name of the first tab (they were synonymous).
6262
*/
6363
private String name;
6464

@@ -664,8 +664,8 @@ public void handleDeleteCode() {
664664
// confirm deletion with user, yes/no
665665
Object[] options = { Language.text("prompt.ok"), Language.text("prompt.cancel") };
666666
String prompt = (currentIndex == 0) ?
667-
Language.text("warn.delete.sketch") :
668-
Language.interpolate("warn.delete.file", current.getPrettyName());
667+
Language.interpolate("warn.delete.sketch_folder", getName()) :
668+
Language.interpolate("warn.delete.sketch_file", current.getPrettyName());
669669
int result = JOptionPane.showOptionDialog(editor,
670670
prompt,
671671
Language.text("warn.delete"),
@@ -675,24 +675,22 @@ public void handleDeleteCode() {
675675
options,
676676
options[0]);
677677
if (result == JOptionPane.YES_OPTION) {
678-
if (currentIndex == 0) {
678+
if (currentIndex == 0) { // delete the entire sketch
679679
// need to unset all the modified flags, otherwise tries
680680
// to do a save on the handleNew()
681681

682-
// delete the entire sketch
683-
Util.removeDir(folder);
684-
685-
// get the changes into the sketchbook menu
686-
//sketchbook.rebuildMenus();
682+
// Attempt to move to the trash (falls back to removeDir)
683+
try {
684+
Platform.deleteFile(folder);
685+
} catch (IOException e) {
686+
e.printStackTrace();
687+
}
687688

688689
// make a new sketch and rebuild the sketch menu
689-
//editor.handleNewUnchecked();
690-
//editor.handleClose2();
691690
editor.getBase().rebuildSketchbook();
692691
editor.getBase().handleClose(editor, false);
693692

694-
} else {
695-
// delete the file
693+
} else { // delete a single tab
696694
if (!current.deleteFile()) {
697695
Messages.showMessage(Language.text("delete.messages.cannot_delete.file"),
698696
Language.text("delete.messages.cannot_delete.file.description")+" \"" +

app/src/processing/app/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static public boolean removeDir(File dir) {
312312

313313
/**
314314
* Remove all files in a directory and the directory itself.
315-
* Optinally prints error messages with failed filenames.
315+
* Optionally, prints error messages with failed filenames.
316316
* Does not follow symlinks.
317317
*/
318318
static public boolean removeDir(File dir, boolean printErrorMessages) {

build/shared/lib/languages/PDE.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ contrib.import.errors.link = Error: The library %s has a strange looking downloa
589589
# Warnings
590590

591591
warn.delete = Delete
592-
warn.delete.sketch = Are you sure you want to delete this sketch?
593-
warn.delete.file = Are you sure you want to delete "%s"?
592+
warn.delete.sketch_folder = Are you sure you want to delete this sketch?\nThis will remove the entire "%s" folder.
593+
warn.delete.sketch_file = Are you sure you want to delete "%s"?
594594
warn.cannot_change_mode.title = Cannot change mode
595595
warn.cannot_change_mode.body = Cannot change mode,\nbecause "%s" mode is not compatible with current mode.
596596

todo.txt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@ X Bring back getMainProgram() for Python Mode
33
X https://github.com/processing/processing4/issues/409
44
X You must first install tweak Mode to use this sketch
55
X https://github.com/processing/processing4/issues/415
6+
_ test with Python Mode before release
7+
8+
sketchbook/open/deletions
9+
X test "obvious" sketch folder (and whether it prompts)
10+
X opening Downloads > something.pde made a p5.js sketch with only an index.html
11+
X if no sketch.properties, reset nextMode to the default mode
12+
X deleting sketch removed contents of Download folder
13+
X https://github.com/processing/processing4/issues/424
14+
X also very problematic for what happens with Save As
15+
X ah, this is because it was just a single .pde file, yikes
16+
X sketch.properties should be present, but won't be if the parent is renamed
17+
o always write sketch.properties? (would help the later rename case)
18+
X when loading, prompt to ask whether the parent folder is the sketch folder?
19+
X if it is, write sketch.properties to set the main file
20+
X if not, move it to its own folder "move blah.pde to a folder named blah"
21+
X are you sure you want to delete the sketch "Downloads"
22+
X instead of "are you sure you want to delete this sketch?"
23+
X have 'delete' function move things to the trash
24+
o or remove 'delete' as an option altogether
25+
X new language string: warn.delete.sketch_folder so we can include folder name
26+
X and renamed warn.delete.file to warn.delete.sketch_file
627

7-
_ deleting sketch removed contents of Download folder
8-
_ https://github.com/processing/processing4/issues/424
9-
_ at a minimum, need to have 'delete' function move things to the trash
10-
_ or remove 'delete' as an option altogether
11-
_ also very problematic for what happens with Save As
12-
_ ah, this is because it was just a single .pde file, yikes
13-
_ sketch.properties should be present, but won't be if the parent is renamed
14-
_ always write sketch.properties? (would help the later rename case)
15-
_ when loading, prompt to ask whether the parent folder is the sketch folder?
16-
_ if it is, write sketch.properties to set the main file
17-
_ if not, move it to its own folder "move blah.pde to a folder named blah"
1828

1929
_ examples handling is less than ideal
2030
_ examples not mentioned in warning dialog when installing

0 commit comments

Comments
 (0)