Changeset 18049 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-07-17T16:24:05+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/ImageData.java
r17579 r18049 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data; 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 3 6 4 import java.util.ArrayList; … … 267 265 /** 268 266 * Remove the current selected image from the list 269 */270 public void removeSelectedImage() {271 List<ImageEntry> selectedImages = getSelectedImages();272 if (selectedImages.size() > 1) {273 throw new IllegalStateException(tr("Multiple images have been selected"));274 }275 removeImages(selectedImages);276 }277 278 /**279 * Remove the current selected image from the list280 267 * @since 15348 281 268 */ 282 269 public void removeSelectedImages() { 283 List<ImageEntry> selectedImages = getSelectedImages(); 284 removeImages(selectedImages); 270 removeImages(getSelectedImages()); 285 271 } 286 272 … … 290 276 } 291 277 for (ImageEntry img: getSelectedImages()) { 292 data.remove(img); 293 this.geoImages.remove(img); 294 } 295 if (selectedImagesIndex.get(0) >= data.size()) { 296 setSelectedImageIndex(data.size() - 1); 278 removeImage(img, false); 279 } 280 updateSelectedImage(); 281 } 282 283 /** 284 * Update the selected image after removal of one or more images. 285 * @since 18049 286 */ 287 public void updateSelectedImage() { 288 int size = data.size(); 289 Integer firstSelectedImageIndex = selectedImagesIndex.get(0); 290 if (firstSelectedImageIndex >= size) { 291 setSelectedImageIndex(size - 1); 297 292 } else { 298 setSelectedImageIndex( selectedImagesIndex.get(0), true);293 setSelectedImageIndex(firstSelectedImageIndex, true); 299 294 } 300 295 } … … 307 302 */ 308 303 public boolean isImageSelected(ImageEntry image) { 309 int index = data.indexOf(image); 310 return selectedImagesIndex.contains(index); 304 return selectedImagesIndex.contains(data.indexOf(image)); 311 305 } 312 306 … … 316 310 */ 317 311 public void removeImage(ImageEntry img) { 312 removeImage(img, true); 313 } 314 315 /** 316 * Remove the image from the list and optionnally trigger update listener 317 * @param img the {@link ImageEntry} to remove 318 * @param fireUpdateEvent if {@code true}, notifies listeners of image update 319 * @since xxx 320 */ 321 public void removeImage(ImageEntry img, boolean fireUpdateEvent) { 318 322 data.remove(img); 319 323 this.geoImages.remove(img); 320 notifyImageUpdate(); 324 if (fireUpdateEvent) { 325 notifyImageUpdate(); 326 } 321 327 } 322 328 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r18018 r18049 344 344 345 345 if (result == 2) { 346 currentData.removeSelectedImages();347 346 for (ImageEntry delete : toDelete) { 348 347 if (Utils.deleteFile(delete.getFile())) { 349 Logging.info("File " + delete.getFile() + " deleted."); 348 currentData.removeImage(delete, false); 349 Logging.info("File {0} deleted.", delete.getFile()); 350 350 } else { 351 351 JOptionPane.showMessageDialog( … … 357 357 } 358 358 } 359 currentData.notifyImageUpdate(); 360 currentData.updateSelectedImage(); 359 361 } 360 362 }
Note:
See TracChangeset
for help on using the changeset viewer.