Changeset 32454 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-06-30T00:08:28+02:00 (9 years ago)
Author:
donvip
Message:

remove calls to deprecated methods

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  
    241241        });
    242242
    243         DataSet currentDs = Main.main.getCurrentDataSet();
     243        DataSet currentDs = Main.getLayerManager().getEditDataSet();
    244244
    245245        if (ds != currentDs) {
     
    280280        // Refresh selection if a node belonging to a selected member has moved (example: scale action)
    281281        if ((nodes != null && nodes.contains(n)) || waysContain(n)) {
    282             selectionChanged(Main.main.getCurrentDataSet().getSelected());
     282            selectionChanged(Main.getLayerManager().getEditDataSet().getSelected());
    283283        }
    284284    }
     
    295295    public void systemOfMeasurementChanged(String oldSoM, String newSoM) {
    296296        // Refresh selection to take into account new system of measurement
    297         DataSet currentDs = Main.main.getCurrentDataSet();
     297        DataSet currentDs = Main.getLayerManager().getEditDataSet();
    298298        if (currentDs != null) {
    299299            selectionChanged(currentDs.getSelected());
  • applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java

    r30641 r32454  
    77import org.openstreetmap.josm.gui.IconToggleButton;
    88import org.openstreetmap.josm.gui.MapFrame;
    9 import org.openstreetmap.josm.gui.MapView;
    10 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    119import org.openstreetmap.josm.gui.layer.Layer;
     10import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     11import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     12import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     13import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     14import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     15import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    1216import org.openstreetmap.josm.plugins.Plugin;
    1317import org.openstreetmap.josm.plugins.PluginInformation;
     
    4246        if (currentLayer == null) {
    4347            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)
    4854                        MeasurementPlugin.currentLayer = (MeasurementLayer)newLayer;
    4955                }
    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
    5162                }
    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
    5576                }
    5677            });
Note: See TracChangeset for help on using the changeset viewer.