- Timestamp:
- 2019-09-15T23:54:42+02:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/ImageData.java
r15348 r15352 247 247 */ 248 248 public void removeSelectedImage() { 249 List<ImageEntry> selected = getSelectedImages();250 if (selected .size() > 1) {249 List<ImageEntry> selectedImages = getSelectedImages(); 250 if (selectedImages.size() > 1) { 251 251 throw new IllegalStateException(tr("Multiple images have been selected")); 252 252 } 253 if (selected.isEmpty()) { 253 removeImages(selectedImages); 254 } 255 256 /** 257 * Remove the current selected image from the list 258 * @since 15348 259 */ 260 public void removeSelectedImages() { 261 List<ImageEntry> selectedImages = getSelectedImages(); 262 removeImages(selectedImages); 263 } 264 265 private void removeImages(List<ImageEntry> selectedImages) { 266 if (selectedImages.isEmpty()) { 254 267 return; 255 268 } 256 data.remove(getSelectedImages().get(0)); 269 for (ImageEntry img: getSelectedImages()) { 270 data.remove(img); 271 } 257 272 if (selectedImagesIndex.get(0) == data.size()) { 258 273 setSelectedImageIndex(data.size() - 1); … … 263 278 264 279 /** 265 * Remove the current selected image from the list266 * @since 15348267 */268 public void removeSelectedImages() {269 List<ImageEntry> selected = getSelectedImages();270 if (selected.isEmpty()) {271 return;272 }273 for (ImageEntry img: getSelectedImages()) {274 data.remove(img);275 }276 setSelectedImageIndex(-1, true);277 }278 279 /**280 280 * Determines if the image is selected 281 281 * @param image the {@link ImageEntry} image -
trunk/test/unit/org/openstreetmap/josm/data/ImageDataTest.java
r15348 r15352 196 196 197 197 @Test 198 public void testSelectImageAfterRemove() { 199 List<ImageEntry> list = getOneImage(); 200 list.add(new ImageEntry()); 201 202 ImageData data = new ImageData(list); 203 data.selectFirstImage(); 204 data.removeSelectedImages(); 205 assertEquals(1, data.getImages().size()); 206 assertEquals(1, data.getSelectedImages().size()); 207 assertEquals(list.get(0), data.getSelectedImages().get(0)); 208 } 209 210 @Test 211 public void testSelectImageAfterRemoveWhenTheLastIsSelected() { 212 List<ImageEntry> list = getOneImage(); 213 list.add(new ImageEntry()); 214 215 ImageData data = new ImageData(list); 216 data.selectLastImage(); 217 data.removeSelectedImages(); 218 assertEquals(1, data.getImages().size()); 219 assertEquals(1, data.getSelectedImages().size()); 220 assertEquals(list.get(0), data.getSelectedImages().get(0)); 221 } 222 223 @Test 198 224 public void testRemoveSelectedImageTriggerListener() { 199 225 List<ImageEntry> list = getOneImage();
Note:
See TracChangeset
for help on using the changeset viewer.