Changeset 13010 in josm


Ignore:
Timestamp:
2017-10-17T11:20:34+02:00 (16 months ago)
Author:
bastiK
Message:

see #14120 - fix use of deprecated API (selection handling)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r12846 r13010  
    22package org.openstreetmap.josm.data;
    33
    4 import java.util.Collection;
    54import java.util.Iterator;
    65import java.util.LinkedList;
    7 import java.util.Optional;
    86
    97import org.openstreetmap.josm.Main;
    108import org.openstreetmap.josm.command.Command;
    119import org.openstreetmap.josm.data.osm.DataSet;
    12 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1310import org.openstreetmap.josm.spi.preferences.Config;
    1411import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    9390     */
    9491    public synchronized void add(final Command c) {
    95         DataSet ds = Optional.ofNullable(c.getAffectedDataSet()).orElseGet(() -> Main.main.getEditDataSet());
    96         Collection<? extends OsmPrimitive> oldSelection = null;
    97         if (ds != null) {
    98             oldSelection = ds.getSelected();
    99         }
    10092        addNoRedraw(c);
    10193        afterAdd();
    102 
    103         // the command may have changed the selection so tell the listeners about the current situation
    104         if (ds != null) {
    105             fireIfSelectionChanged(ds, oldSelection);
    106         }
    10794    }
    10895
     
    122109            return;
    123110        DataSet ds = Main.main.getEditDataSet();
    124         Collection<? extends OsmPrimitive> oldSelection = null;
    125111        if (ds != null) {
    126             oldSelection = ds.getSelected();
    127112            ds.beginUpdate();
    128113        }
     
    142127        }
    143128        fireCommandsChanged();
    144         if (ds != null) {
    145             fireIfSelectionChanged(ds, oldSelection);
    146         }
    147129    }
    148130
     
    161143        if (redoCommands.isEmpty())
    162144            return;
    163         DataSet ds = Main.main.getEditDataSet();
    164         Collection<? extends OsmPrimitive> oldSelection = ds.getSelected();
    165145        for (int i = 0; i < num; ++i) {
    166146            final Command c = redoCommands.removeFirst();
     
    172152        }
    173153        fireCommandsChanged();
    174         fireIfSelectionChanged(ds, oldSelection);
    175     }
    176 
    177     private static void fireIfSelectionChanged(DataSet ds, Collection<? extends OsmPrimitive> oldSelection) {
    178         Collection<? extends OsmPrimitive> newSelection = ds.getSelected();
    179         if (!oldSelection.equals(newSelection)) {
    180             ds.fireSelectionChanged();
    181         }
    182154    }
    183155
Note: See TracChangeset for help on using the changeset viewer.