Changeset 32454 in osm
- Timestamp:
- 2016-06-30T00:08:28+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/measurement
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r32324 r32454 241 241 }); 242 242 243 DataSet currentDs = Main. main.getCurrentDataSet();243 DataSet currentDs = Main.getLayerManager().getEditDataSet(); 244 244 245 245 if (ds != currentDs) { … … 280 280 // Refresh selection if a node belonging to a selected member has moved (example: scale action) 281 281 if ((nodes != null && nodes.contains(n)) || waysContain(n)) { 282 selectionChanged(Main. main.getCurrentDataSet().getSelected());282 selectionChanged(Main.getLayerManager().getEditDataSet().getSelected()); 283 283 } 284 284 } … … 295 295 public void systemOfMeasurementChanged(String oldSoM, String newSoM) { 296 296 // Refresh selection to take into account new system of measurement 297 DataSet currentDs = Main. main.getCurrentDataSet();297 DataSet currentDs = Main.getLayerManager().getEditDataSet(); 298 298 if (currentDs != null) { 299 299 selectionChanged(currentDs.getSelected()); -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java
r30641 r32454 7 7 import org.openstreetmap.josm.gui.IconToggleButton; 8 8 import org.openstreetmap.josm.gui.MapFrame; 9 import org.openstreetmap.josm.gui.MapView;10 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;11 9 import org.openstreetmap.josm.gui.layer.Layer; 10 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 11 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 12 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 13 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 14 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 15 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 12 16 import org.openstreetmap.josm.plugins.Plugin; 13 17 import org.openstreetmap.josm.plugins.PluginInformation; … … 42 46 if (currentLayer == null) { 43 47 currentLayer = new MeasurementLayer(tr("Measurements")); 44 Main.main.addLayer(currentLayer); 45 MapView.addLayerChangeListener(new LayerChangeListener(){ 46 public void activeLayerChange(final Layer oldLayer, final Layer newLayer) { 47 if(newLayer instanceof MeasurementLayer) 48 Main.getLayerManager().addLayer(currentLayer); 49 final ActiveLayerChangeListener activeListener = new ActiveLayerChangeListener() { 50 @Override 51 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 52 Layer newLayer = Main.getLayerManager().getActiveLayer(); 53 if (newLayer instanceof MeasurementLayer) 48 54 MeasurementPlugin.currentLayer = (MeasurementLayer)newLayer; 49 55 } 50 public void layerAdded(final Layer newLayer) { 56 }; 57 Main.getLayerManager().addActiveLayerChangeListener(activeListener); 58 Main.getLayerManager().addLayerChangeListener(new LayerChangeListener(){ 59 @Override 60 public void layerAdded(LayerAddEvent e) { 61 // Do nothing 51 62 } 52 public void layerRemoved(final Layer oldLayer) { 53 if (oldLayer != null && oldLayer == currentLayer) 54 MapView.removeLayerChangeListener(this); 63 64 @Override 65 public void layerRemoving(LayerRemoveEvent e) { 66 Layer oldLayer = e.getRemovedLayer(); 67 if (oldLayer != null && oldLayer == currentLayer) { 68 Main.getLayerManager().removeActiveLayerChangeListener(activeListener); 69 Main.getLayerManager().removeLayerChangeListener(this); 70 } 71 } 72 73 @Override 74 public void layerOrderChanged(LayerOrderChangeEvent e) { 75 // Do nothing 55 76 } 56 77 });
Note:
See TracChangeset
for help on using the changeset viewer.