Move sketch deletion from SketchController into Sketch

This isn't much code, but it makes deletion more consistent with
renaming and saving with the SketchController handling the UI part and
Sketch actually doing the delete.
This commit is contained in:
Matthijs Kooijman 2015-12-29 17:01:10 +01:00 committed by Martino Facchin
parent 85d48394a4
commit ccec28ea45
2 changed files with 8 additions and 13 deletions

View File

@ -249,20 +249,8 @@ public class SketchController {
options[0]);
if (result == JOptionPane.YES_OPTION) {
if (current.isPrimary()) {
// need to unset all the modified flags, otherwise tries
// to do a save on the handleNew()
// delete the entire sketch
FileUtils.recursiveDelete(sketch.getFolder());
// get the changes into the sketchbook menu
//sketchbook.rebuildMenus();
// make a new sketch, and i think this will rebuild the sketch menu
//editor.handleNewUnchecked();
//editor.handleClose2();
sketch.delete();
editor.base.handleClose(editor);
} else {
// delete the file
if (!current.deleteFile(BaseNoGui.getBuildFolder(sketch).toPath())) {

View File

@ -332,4 +332,11 @@ public class Sketch {
FileUtils.copy(getDataFolder(), newDataFolder);
}
}
/**
* Deletes this entire sketch from disk.
*/
void delete() {
FileUtils.recursiveDelete(folder);
}
}