Changeset 32863 in osm for applications/editors
- Timestamp:
- 2016-08-21T20:23:56+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java
r32756 r32863 43 43 private IconToggleButton mmButton; 44 44 private PhotoAdjustWorker worker; 45 /** True if one existing GeoImageLayer is to be ignored. */ 46 private boolean ignoreOneGILayer = false; 45 47 46 48 public PhotoAdjustMapMode(MapFrame mapFrame, PhotoAdjustWorker worker) { … … 55 57 initAdapters(); 56 58 this.worker = worker; 59 Main.getLayerManager().addLayerChangeListener(this); 60 Main.getLayerManager().addActiveLayerChangeListener(this); 57 61 } 58 62 … … 133 137 super.enterMode(); 134 138 modeSelected = true; 135 Main.getLayerManager().addLayerChangeListener(this);136 Main.getLayerManager().addActiveLayerChangeListener(this);137 139 // Activate the mode only if the current layer is not a GeoImageLayer. 138 140 // GeoImageLayer's are handled by the plug-in directly. … … 145 147 public void exitMode() { 146 148 super.exitMode(); 147 Main.getLayerManager().removeActiveLayerChangeListener(this);148 Main.getLayerManager().removeLayerChangeListener(this);149 149 deactivateMode(); 150 150 modeSelected = false; … … 168 168 169 169 @Override 170 public void layerRemoving(LayerRemoveEvent e) { 170 public void layerRemoving(LayerRemoveEvent lre) { 171 if (lre.getRemovedLayer() instanceof GeoImageLayer) { 172 // A GeoImageLayer is about to be removed. We ignore this layer 173 // in the following update methods to get the correct number of 174 // future GeoImageLayers. 175 ignoreOneGILayer = true; 176 } 171 177 if (modeActive) updateStatusLine(); 172 178 updateButtonState(); 179 ignoreOneGILayer = false; 173 180 } 174 181 … … 213 220 private boolean hasLayersToAdjust() { 214 221 if (Main.map == null || Main.map.mapView == null) return false; 215 return ! Main.getLayerManager().getLayersOfType(GeoImageLayer.class).isEmpty(); 222 int giLayerNum = Main.getLayerManager().getLayersOfType(GeoImageLayer.class).size(); 223 if (ignoreOneGILayer) { 224 giLayerNum--; 225 } 226 return giLayerNum > 0; 216 227 } 217 228 … … 229 240 return all; 230 241 } 242 243 244 @Override 245 public void destroy() { 246 super.destroy(); 247 Main.getLayerManager().removeActiveLayerChangeListener(this); 248 Main.getLayerManager().removeLayerChangeListener(this); 249 } 250 231 251 }
Note:
See TracChangeset
for help on using the changeset viewer.