- Timestamp:
- 11/12/19 15:39:05 (4 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gio/gesture/StandardGestureActions.java
r1446 r1448 1 1 package org.expeditee.gio.gesture; 2 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.nio.file.Files; 6 import java.nio.file.Path; 7 import java.nio.file.Paths; 8 import java.nio.file.StandardCopyOption; 3 9 import java.text.NumberFormat; 4 10 import java.util.ArrayList; … … 3245 3251 } 3246 3252 Collection<Item> toUndo = null; 3253 List<Path> canditateFilesToDelete = new ArrayList<Path>(); 3247 3254 if (toDelete.isLineEnd()) { 3248 3255 // delete the entire connected shape if shift is down … … 3290 3297 bRecalculate |= toDelete.recalculateWhenChanged(); 3291 3298 toUndo = toDelete.getConnected(); // copy(toDelete.getConnected()); 3299 if (toDelete instanceof Picture && alternateMode) { 3300 String pathStr = ((Picture) toDelete).getPath(); 3301 Path path = Paths.get(pathStr); 3302 canditateFilesToDelete.add(path); 3303 } 3292 3304 } 3293 3305 SessionStats.DeletedItems(toUndo); … … 3295 3307 parent.addToUndoDelete(new ItemsList(toUndo)); 3296 3308 parent.removeAllItems(toUndo); // toDelete.getConnected() 3309 deleteUnusedFiles(canditateFilesToDelete); 3297 3310 } 3298 3311 // reset the mouse cursor … … 3314 3327 3315 3328 DisplayController.requestRefresh(true); 3329 } 3330 3331 private static void deleteUnusedFiles(List<Path> canditateFilesToDelete) { 3332 for (Path p: canditateFilesToDelete) { 3333 try { 3334 Path trashPath = Paths.get(FrameIO.TRASH_PATH); 3335 trashPath.toFile().mkdirs(); 3336 Path destination = trashPath.resolve(p.getFileName()); 3337 Files.move(p, destination, StandardCopyOption.ATOMIC_MOVE); 3338 } catch (IOException e) { 3339 MessageBay.displayMessage("There was a problem moving a file to the trash. File: " + p.getFileName()); 3340 } 3341 } 3316 3342 } 3317 3343 -
trunk/src/org/expeditee/gui/Frame.java
r1445 r1448 20 20 21 21 import java.io.File; 22 import java.io.IOException; 23 import java.nio.file.Files; 24 import java.nio.file.Path; 22 25 import java.nio.file.Paths; 26 import java.nio.file.StandardCopyOption; 23 27 import java.sql.Time; 24 28 import java.util.ArrayList; … … 1096 1100 _redo.push(undo); 1097 1101 for(Item i : undo.items) { 1102 if (i instanceof org.expeditee.items.Picture) { 1103 String destination = ((org.expeditee.items.Picture) i).getPath(); 1104 Path destinationPath = Paths.get(destination); 1105 Path sourcePath = Paths.get(FrameIO.TRASH_PATH).resolve(destinationPath.getFileName()); 1106 try { 1107 Files.move(sourcePath, destinationPath, StandardCopyOption.ATOMIC_MOVE); 1108 } catch (IOException e) { 1109 MessageBay.displayMessage("Unable to restore image file from trash, not undoing deletion of image."); 1110 continue; 1111 } 1112 } 1098 1113 this.addItem(i); 1099 1114 reparse |= i.hasOverlay();
Note:
See TracChangeset
for help on using the changeset viewer.