Ticket #21430: 21430.patch
File 21430.patch, 3.3 KB (added by , 3 years ago) |
---|
-
src/org/openstreetmap/josm/data/imagery/street_level/IImageEntry.java
93 93 } 94 94 95 95 /** 96 * Delete the image 97 * @return {@code true} if deletion was successful 98 * @throws UnsupportedOperationException If the implementation does not support deletion. 99 * Use {@link #isDeleteSupported()}} to check for support. 100 */ 101 102 default boolean delete() { 103 throw new UnsupportedOperationException("remove is not supported for " + this.getClass().getSimpleName()); 104 } 105 /** 106 * Check if image deletion is supported 107 * @return {@code true} if deletion is supported 108 */ 109 default boolean isDeleteSupported() { 110 return false; 111 } 112 113 /** 96 114 * Returns a display name for this entry (shown in image viewer title bar) 97 115 * @return a display name for this entry 98 116 */ -
src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
25 25 import org.openstreetmap.josm.tools.ExifReader; 26 26 import org.openstreetmap.josm.tools.ImageProvider; 27 27 import org.openstreetmap.josm.tools.Logging; 28 import org.openstreetmap.josm.tools.Utils; 28 29 29 30 /** 30 31 * Stores info about each image, with an optional thumbnail … … 190 191 return true; 191 192 } 192 193 194 @Override 195 public boolean isDeleteSupported() { 196 return true; 197 } 198 199 @Override 200 public boolean delete() { 201 return Utils.deleteFile(this.getFile()); 202 } 203 193 204 /** 194 205 * Reads the image represented by this entry in the given target dimension. 195 206 * @param target the desired dimension used for {@linkplain IIOParam#setSourceSubsampling subsampling} or {@code null} -
src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
358 358 final List<ImageData> imageDataCollection = toDelete.stream().filter(ImageEntry.class::isInstance) 359 359 .map(ImageEntry.class::cast).map(ImageEntry::getDataSet).distinct().collect(Collectors.toList()); 360 360 for (IImageEntry<?> delete : toDelete) { 361 if (delete.isRemoveSupported() && delete.remove()) { 361 // We have to be able to remove the image from the layer and the image from its storage location 362 // If either are false, then don't remove the image. 363 if (delete.isRemoveSupported() && delete.isDeleteSupported() && delete.remove() && delete.delete()) { 362 364 Logging.info("File {0} deleted.", delete.getFile()); 363 365 } else { 364 366 JOptionPane.showMessageDialog(