Changeset 7444 in josm
- Timestamp:
- 2014-08-27T00:53:36+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
r7426 r7444 23 23 24 24 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.gui.MapView; 26 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 25 27 import org.openstreetmap.josm.gui.dialogs.DialogsPanel.Action; 26 28 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 29 import org.openstreetmap.josm.gui.layer.Layer; 27 30 import org.openstreetmap.josm.tools.ImageProvider; 28 31 import org.openstreetmap.josm.tools.Shortcut; 29 32 import org.openstreetmap.josm.tools.date.DateUtils; 30 33 31 public final class ImageViewerDialog extends ToggleDialog {34 public final class ImageViewerDialog extends ToggleDialog implements LayerChangeListener { 32 35 33 36 private static final String COMMAND_ZOOM = "zoom"; … … 87 90 btnPrevious.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scPrev.getKeyStroke(), APREVIOUS); 88 91 btnPrevious.getActionMap().put(APREVIOUS, prevAction); 92 btnPrevious.setEnabled(false); 89 93 90 94 final String DELETE_TEXT = tr("Remove photo from layer"); … … 117 121 btnNext.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(scNext.getKeyStroke(), ANEXT); 118 122 btnNext.getActionMap().put(ANEXT, nextAction); 123 btnNext.setEnabled(false); 119 124 120 125 Main.registerActionShortcut( … … 167 172 168 173 add(content, BorderLayout.CENTER); 174 175 MapView.addLayerChangeListener(this); 176 } 177 178 @Override 179 public void destroy() { 180 MapView.removeLayerChangeListener(this); 181 super.destroy(); 169 182 } 170 183 … … 218 231 public static void showImage(GeoImageLayer layer, ImageEntry entry) { 219 232 getInstance().displayImage(layer, entry); 220 layer.checkPreviousNextButtons(); 221 } 222 public static void setPreviousEnabled(Boolean value) { 233 if (layer != null) { 234 layer.checkPreviousNextButtons(); 235 } else { 236 setPreviousEnabled(false); 237 setNextEnabled(false); 238 } 239 } 240 241 /** 242 * Enables (or disables) the "Previous" button. 243 * @param value {@code true} to enable the button, {@code false} otherwise 244 */ 245 public static void setPreviousEnabled(boolean value) { 223 246 getInstance().btnPrevious.setEnabled(value); 224 247 } 225 public static void setNextEnabled(Boolean value) { 248 249 /** 250 * Enables (or disables) the "Next" button. 251 * @param value {@code true} to enable the button, {@code false} otherwise 252 */ 253 public static void setNextEnabled(boolean value) { 226 254 getInstance().btnNext.setEnabled(value); 227 255 } … … 285 313 } 286 314 } 287 288 315 } 289 316 … … 334 361 return getInstance().currentLayer; 335 362 } 363 364 @Override 365 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 366 // Ignored 367 } 368 369 @Override 370 public void layerAdded(Layer newLayer) { 371 // Ignored 372 } 373 374 @Override 375 public void layerRemoved(Layer oldLayer) { 376 // Clear current image and layer if current layer is deleted 377 if (currentLayer != null && currentLayer.equals(oldLayer)) { 378 showImage(null, null); 379 } 380 } 336 381 }
Note:
See TracChangeset
for help on using the changeset viewer.