Changeset 35476 in osm for applications/editors


Ignore:
Timestamp:
2020-05-29T11:26:52+02:00 (5 years ago)
Author:
gerdp
Message:

fix #josm19313: use getActiveDataSet() instead of getEditDataSet() where appropriate
minor other improvements (errorprone, sonarlint, deprecations)

Location:
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/CopyTagsAction.java

    r34454 r35476  
    88import java.awt.event.KeyEvent;
    99import java.util.Collection;
    10 import java.util.Map.Entry;
    1110import java.util.Set;
    1211import java.util.TreeSet;
     12import java.util.stream.Collectors;
    1313
    1414import javax.swing.JOptionPane;
     
    2121import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2222import org.openstreetmap.josm.tools.Shortcut;
    23 import org.openstreetmap.josm.tools.Utils;
    2423
    2524/**
     
    4645    public void actionPerformed(ActionEvent e) {
    4746        if (isEmptySelection()) return;
    48         Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
     47        Collection<OsmPrimitive> selection = getLayerManager().getActiveDataSet().getSelected();
    4948        copy(getLayerManager().getEditLayer(), selection);
    5049    }
     
    5958        Set<String> values = new TreeSet<>();
    6059        for (OsmPrimitive p : primitives) {
    61             for (Entry<String, String> kv : p.getKeys().entrySet()) {
    62                 values.add(new Tag(kv.getKey(), kv.getValue()).toString());
    63             }
     60            p.getKeys().entrySet().forEach(kv -> values.add(new Tag(kv.getKey(), kv.getValue()).toString()));
    6461        }
    65         if (!values.isEmpty())
    66             ClipboardUtils.copyString(Utils.join("\n", values));
     62        if (!values.isEmpty()) {
     63            ClipboardUtils.copyString(values.stream().collect(Collectors.joining("\n")));
     64        }
    6765    }
    6866
     
    7876
    7977    private boolean isEmptySelection() {
    80         Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
     78        Collection<OsmPrimitive> sel = getLayerManager().getActiveDataSet().getSelected();
    8179        if (sel.isEmpty()) {
    8280            JOptionPane.showMessageDialog(
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java

    r34822 r35476  
    1414import java.util.List;
    1515import java.util.Map;
    16 import java.util.Map.Entry;
    1716
    1817import org.openstreetmap.josm.actions.JosmAction;
     
    8079
    8180        List<Command> commands = new ArrayList<>();
    82         for (Entry<Relation, String> entry : relations.entrySet()) {
     81        for (Map.Entry<Relation, String> entry : relations.entrySet()) {
    8382            Relation rel = entry.getKey();
    8483            Relation r = new Relation(rel);
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java

    r35366 r35476  
    1515import java.util.List;
    1616import java.util.Map;
    17 import java.util.Map.Entry;
    1817
    1918import javax.swing.JOptionPane;
     
    121120            }
    122121
    123             for (Entry<Way, Integer> entry : wayOccurenceCounter.entrySet()) {
     122            for (Map.Entry<Way, Integer> entry : wayOccurenceCounter.entrySet()) {
    124123                if (entry.getValue().equals(selectedNodes.size())) {
    125124                    if (selectedWay != null) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java

    r34816 r35476  
    1212import java.util.List;
    1313import java.util.Map;
    14 import java.util.Map.Entry;
    1514
    1615import javax.swing.JOptionPane;
     
    9291        }
    9392
    94         for (Entry<Way, List<Node>> entry : splitWays.entrySet()) {
     93        for (Map.Entry<Way, List<Node>> entry : splitWays.entrySet()) {
    9594            SplitWayCommand split = SplitWayCommand.split(entry.getKey(), entry.getValue(), selectedWays);
    9695            if (split != null) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CircleArcMaker.java

    r35440 r35476  
    266266                PolarCoor pcLast = new PolarCoor(last.getEastNorth(), center);
    267267                double delta = pcLast.angle - pcFirst.angle;
    268                 if ((!clockwise && delta < 0 || clockwise && delta > 0)
     268                if (((!clockwise && delta < 0) || (clockwise && delta > 0))
    269269                        && Math.signum(pcFirst.angle) == Math.signum(pcLast.angle)) {
    270270                    // cannot project node onto circle arc, ignore that it is fixed
     
    300300                    if (!oldNodes.isEmpty()) {
    301301                        PolarCoor pc2 = new PolarCoor(oldNodes.get(0).getEastNorth(), center);
    302                         if (pc2.angle < ref.angle && ref.angle < 0 && step > 0
    303                                 || pc2.angle > ref.angle && ref.angle > 0 && step < 0) {
     302                        if ((pc2.angle < ref.angle && ref.angle < 0 && step > 0)
     303                                || (pc2.angle > ref.angle && ref.angle > 0 && step < 0)) {
    304304                            // projected node would produce a loop
    305305                            pc2 = ref; //
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java

    r35472 r35476  
    4444    @Override
    4545    protected void updateEnabledState() {
    46         setEnabled(getLayerManager().getEditDataSet() != null);
     46        setEnabled(getLayerManager().getActiveDataSet() != null);
    4747    }
    4848
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/OpenPageAction.java

    r35472 r35476  
    4343    @Override
    4444    public void actionPerformed(ActionEvent e) {
    45         Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected();
     45        Collection<OsmPrimitive> sel = getLayerManager().getActiveDataSet().getSelected();
    4646        OsmPrimitive p = null;
    47         if (sel.size() >= 1) {
     47        if (!sel.isEmpty()) {
    4848            p = sel.iterator().next();
    4949        }
     
    6565            while (m.find()) {
    6666                key = m.group(1); val = null;
    67                 if (key.equals("#id")) {
     67                if ("#id".equals(key)) {
    6868                    if (p != null) {
    6969                        val = Long.toString(p.getId());
     
    7272                        return;
    7373                    }
    74                 } else if (key.equals("#type")) {
     74                } else if ("#type".equals(key)) {
    7575                    if (p != null) val = OsmPrimitiveType.from(p).getAPIName();
    76                 } else if (key.equals("#lat")) {
     76                } else if ("#lat".equals(key)) {
    7777                    val = Double.toString(center.lat());
    78                 } else if (key.equals("#lon")) {
     78                } else if ("#lon".equals(key)) {
    7979                    val = Double.toString(center.lon());
    80                 } else if (key.equals("#zoom")) {
     80                } else if ("#zoom".equals(key)) {
    8181                    val = Integer.toString(OsmUrlToBounds.getZoom(MainApplication.getMap().mapView.getRealBounds()));
    8282                } else {
     
    115115    @Override
    116116    protected void updateEnabledState() {
    117         setEnabled(getLayerManager().getEditDataSet() != null);
     117        setEnabled(getLayerManager().getActiveDataSet() != null);
    118118    }
    119119}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/latlon/LatLonDialog.java

    r35238 r35476  
    2727import javax.swing.JTextArea;
    2828import javax.swing.UIManager;
    29 import javax.swing.event.ChangeEvent;
    30 import javax.swing.event.ChangeListener;
    3129import javax.swing.event.DocumentEvent;
    3230import javax.swing.event.DocumentListener;
     
    5048    public JTabbedPane tabs;
    5149    private JTextArea taLatLon;
    52     private JScrollPane spScroll;
    5350    private JRadioButton rbNodes;
    5451    private JRadioButton rbWay;
     
    9188        taLatLon = new JTextArea(5, 24);
    9289        taLatLon.getDocument().addDocumentListener(new CoordinateListener());
    93         spScroll = new JScrollPane(taLatLon);
     90        JScrollPane spScroll = new JScrollPane(taLatLon);
    9491        pnl.add(spScroll, GBC.eol().insets(0, 10, 0, 0).fill().weight(2.0, 2.0));
    9592
     
    161158        tabs = new JTabbedPane();
    162159        tabs.addTab(tr("Lat/Lon"), buildLatLon());
    163         tabs.getModel().addChangeListener(new ChangeListener() {
    164             @Override
    165             public void stateChanged(ChangeEvent e) {
    166                 switch (tabs.getModel().getSelectedIndex()) {
    167                 case 0: parseLatLonUserInput(); break;
    168                 default: throw new AssertionError();
    169                 }
     160        tabs.getModel().addChangeListener(e -> {
     161            if (tabs.getModel().getSelectedIndex() == 0) {
     162                parseLatLonUserInput();
     163            } else {
     164                throw new AssertionError();
    170165            }
    171166        });
     
    174169
    175170    public LatLonDialog(Component parent, String title, String help) {
    176         super(MainApplication.getMainFrame(), tr("Add Node..."), new String[] {tr("Ok"), tr("Cancel")});
    177         setButtonIcons(new String[] {"ok", "cancel"});
     171        super(MainApplication.getMainFrame(), tr("Add Node..."), tr("Ok"), tr("Cancel"));
     172        setButtonIcons("ok", "cancel");
    178173        configureContextsensitiveHelp("/Action/AddNode", true);
    179174
     
    230225        //
    231226        NumberFormat f = NumberFormat.getNumberInstance();
    232         Number n = null;
    233227        ParsePosition pp = new ParsePosition(0);
    234         n = f.parse(input, pp);
     228        Number n = f.parse(input, pp);
    235229        if (pp.getErrorIndex() >= 0 || pp.getIndex() < input.length()) {
    236230            // fall back - try to parse with the english locale
     
    249243        try {
    250244            latLons = parseLatLons(taLatLon.getText());
    251             Boolean working = true;
     245            boolean working = true;
    252246            int i = 0;
    253247            while (working && i < latLons.length) {
     
    273267
    274268    private void setOkEnabled(boolean b) {
    275         if (buttons != null && buttons.size() > 0) {
     269        if (buttons != null && !buttons.isEmpty()) {
    276270            buttons.get(0).setEnabled(b);
    277271        }
     
    354348                sb.append("x");     // cardinal direction
    355349                String c = m.group(7).toUpperCase();
    356                 if (c.equals("N") || c.equals("S") || c.equals("E") || c.equals("W")) {
     350                if ("N".equals(c) || "S".equals(c) || "E".equals(c) || "W".equals(c)) {
    357351                    list.add(c);
    358352                } else {
     
    441435
    442436        double coord = (coordDeg < 0 ? -1 : 1) * (Math.abs(coordDeg) + coordMin / 60 + coordSec / 3600);
    443         coord = card.equals("N") || card.equals("E") ? coord : -coord;
    444         if (card.equals("N") || card.equals("S")) {
     437        coord = "N".equals(card) || "E".equals(card) ? coord : -coord;
     438        if ("N".equals(card) || "S".equals(card)) {
    445439            latLon.lat = coord;
    446440        } else {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/multitagger/MultiTagDialog.java

    r35436 r35476  
    1010import java.awt.GridBagLayout;
    1111import java.awt.event.ActionEvent;
    12 import java.awt.event.ActionListener;
    1312import java.awt.event.ItemEvent;
    1413import java.awt.event.ItemListener;
     
    9796        final JToggleButton jt = new JToggleButton("", ImageProvider.get("restart"), true);
    9897        jt.setToolTipText(tr("Sync with JOSM selection"));
    99         jt.addActionListener(new ActionListener() {
    100             @Override public void actionPerformed(ActionEvent e) {
    101                 tableModel.setWatchSelection(jt.isSelected());
    102             }
    103         });
     98        jt.addActionListener(e -> tableModel.setWatchSelection(jt.isSelected()));
    10499        pnl.add(jt, GBC.eol());
    105100
     
    136131        for (final OsmPrimitiveType type: OsmPrimitiveType.values()) {
    137132            final JToggleButton jt = new JToggleButton("", ImageProvider.get(type), true);
    138             jt.addActionListener(new ActionListener() {
    139                 @Override
    140                 public void actionPerformed(ActionEvent e) {
    141                     if (jt.isSelected()) tableModel.shownTypes.add(type); else tableModel.shownTypes.remove(type);
    142                     tableModel.updateData(MainApplication.getLayerManager().getEditDataSet().getSelected());
    143                 }
     133            jt.addActionListener(e -> {
     134                if (jt.isSelected())
     135                    tableModel.shownTypes.add(type);
     136                else
     137                    tableModel.shownTypes.remove(type);
     138                tableModel.updateData(MainApplication.getLayerManager().getEditDataSet().getSelected());
    144139            });
    145140            ImageProvider.get(type);
     
    193188
    194189    };
     190
    195191    private final ListSelectionListener selectionListener = new ListSelectionListener() {
    196192        @Override
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/ConnectedMatch.java

    r35436 r35476  
    3232        Set<Node> matchedNodes = new HashSet<>();
    3333        // find all ways that match the expression
    34         Collection<Way> allWays = MainApplication.getLayerManager().getEditDataSet().getWays();
     34        Collection<Way> allWays = MainApplication.getLayerManager().getActiveDataSet().getWays();
    3535        for (Way way : allWays) {
    3636            if (match.match(way)) {
     
    3939        }
    4040        // find all nodes that match the expression
    41         Collection<Node> allNodes = MainApplication.getLayerManager().getEditDataSet().getNodes();
     41        Collection<Node> allNodes = MainApplication.getLayerManager().getActiveDataSet().getNodes();
    4242        for (Node node : allNodes) {
    4343            if (match.match(node)) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/InsideMatch.java

    r35436 r35476  
    2929        Collection<OsmPrimitive> matchedAreas = new HashSet<>();
    3030        // find all ways that match the expression
    31         Collection<Way> ways = MainApplication.getLayerManager().getEditDataSet().getWays();
     31        Collection<Way> ways = MainApplication.getLayerManager().getActiveDataSet().getWays();
    3232        for (Way way : ways) {
    3333            if (match.match(way)) {
     
    3636        }
    3737        // find all relations that match the expression
    38         Collection<Relation> rels = MainApplication.getLayerManager().getEditDataSet().getRelations();
     38        Collection<Relation> rels = MainApplication.getLayerManager().getActiveDataSet().getRelations();
    3939        for (Relation rel : rels) {
    4040            if (match.match(rel)) {
     
    4242            }
    4343        }
    44         inside = NodeWayUtils.selectAllInside(matchedAreas, MainApplication.getLayerManager().getEditDataSet(), false);
     44        inside = NodeWayUtils.selectAllInside(matchedAreas, MainApplication.getLayerManager().getActiveDataSet(), false);
    4545    }
    4646
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/search/IntersectingMatch.java

    r34822 r35476  
    3131        Collection<Way> matchedWays = new HashSet<>();
    3232        // find all ways that match the expression
    33         Collection<Way> allWays = MainApplication.getLayerManager().getEditDataSet().getWays();
     33        Collection<Way> allWays = MainApplication.getLayerManager().getActiveDataSet().getWays();
    3434        for (Way way : allWays) {
    3535            if (match.match(way)) {
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentNodesAction.java

    r35470 r35476  
    3737    @Override
    3838    public void actionPerformed(ActionEvent e) {
    39         DataSet ds = getLayerManager().getEditDataSet();
     39        DataSet ds = getLayerManager().getActiveDataSet();
    4040        Collection<Node> selectedNodes = ds.getSelectedNodes();
    4141        Set<Way> selectedWays = new LinkedHashSet<>(ds.getSelectedWays());
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/AdjacentWaysAction.java

    r34812 r35476  
    3535    @Override
    3636    public void actionPerformed(ActionEvent e) {
    37         DataSet ds = getLayerManager().getEditDataSet();
     37        DataSet ds = getLayerManager().getActiveDataSet();
    3838        Collection<Node> selectedNodes = ds.getSelectedNodes();
    3939        Collection<Way> selectedWays = ds.getSelectedWays();
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/ConnectedWaysAction.java

    r34812 r35476  
    3232    @Override
    3333    public void actionPerformed(ActionEvent e) {
    34         DataSet ds = getLayerManager().getEditDataSet();
     34        DataSet ds = getLayerManager().getActiveDataSet();
    3535        Collection<Node> selectedNodes = ds.getSelectedNodes();
    3636        Collection<Way> selectedWays = ds.getSelectedWays();
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysAction.java

    r34812 r35476  
    3434    @Override
    3535    public void actionPerformed(ActionEvent e) {
    36         DataSet ds = getLayerManager().getEditDataSet();
     36        DataSet ds = getLayerManager().getActiveDataSet();
    3737        Collection<Way> selectedWays = ds.getSelectedWays();
    3838
     
    4444                    selectedWays, newWays);
    4545            ds.addSelected(newWays);
    46             return;
    4746        } else {
    4847            new Notification(
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/IntersectedWaysRecursiveAction.java

    r34812 r35476  
    3535    @Override
    3636    public void actionPerformed(ActionEvent e) {
    37         DataSet ds = getLayerManager().getEditDataSet();
     37        DataSet ds = getLayerManager().getActiveDataSet();
    3838        Collection<Way> selectedWays = ds.getSelectedWays();
    3939
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/MiddleNodesAction.java

    r35468 r35476  
    3535    @Override
    3636    public void actionPerformed(ActionEvent e) {
    37         Set<Node> selectedNodes = new HashSet<>(getLayerManager().getEditDataSet().getSelectedNodes());
     37        Set<Node> selectedNodes = new HashSet<>(getLayerManager().getActiveDataSet().getSelectedNodes());
    3838
    3939        // if no 2 nodes and no ways are selected, do nothing
     
    4949
    5050        // make sure that selected nodes are in the wanted order (see #josm17258)
    51         getLayerManager().getEditDataSet().clearSelection(newSelectedNodes);
    52         getLayerManager().getEditDataSet().addSelected(newSelectedNodes);
     51        getLayerManager().getActiveDataSet().clearSelection(newSelectedNodes);
     52        getLayerManager().getActiveDataSet().addSelected(newSelectedNodes);
    5353    }
    5454
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectAllInsideAction.java

    r33212 r35476  
    3232    @Override
    3333    public void actionPerformed(ActionEvent e) {
    34         DataSet ds = getLayerManager().getEditDataSet();
     34        DataSet ds = getLayerManager().getActiveDataSet();
    3535        Collection<OsmPrimitive> insideSelected = NodeWayUtils.selectAllInside(ds.getSelected(), ds, true);
    3636
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java

    r35174 r35476  
    4141    @Override
    4242    public void actionPerformed(ActionEvent e) {
    43         DataSet ds = getLayerManager().getEditDataSet();
     43        DataSet ds = getLayerManager().getActiveDataSet();
    4444        if (ds != null) {
    4545            Collection<Way> selectedWays = ds.getSelectedWays();
     
    9797    @Override
    9898    protected void updateEnabledState() {
    99         setEnabled(getLayerManager().getEditDataSet() != null);
     99        setEnabled(getLayerManager().getActiveDataSet() != null);
    100100    }
    101101
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectHighwayAction.java

    r34932 r35476  
    4141    @Override
    4242    public void actionPerformed(ActionEvent e) {
    43         DataSet ds = getLayerManager().getEditDataSet();
     43        DataSet ds = getLayerManager().getActiveDataSet();
    4444        List<Way> selectedWays = new ArrayList<>(ds.getSelectedWays());
    4545
     
    5555    }
    5656
    57     private Set<Way> selectNamedRoad(Way firstWay) {
     57    private static Set<Way> selectNamedRoad(Way firstWay) {
    5858        Set<Way> newWays = new HashSet<>();
    5959        String key = firstWay.hasKey("name") ? "name" : "ref";
     
    7575    }
    7676
    77     private Set<Way> selectHighwayBetween(Way firstWay, Way lastWay) {
     77    private static Set<Way> selectHighwayBetween(Way firstWay, Way lastWay) {
    7878        int minRank = Math.min(getHighwayRank(firstWay), getHighwayRank(lastWay));
    7979        HighwayTree firstTree = new HighwayTree(firstWay, minRank);
     
    9595            return 0;
    9696        String highway = way.get("highway");
    97         if (highway.equals("path") || highway.equals("footway") || highway.equals("cycleway"))
     97        if ("path".equals(highway) || "footway".equals(highway) || "cycleway".equals(highway))
    9898            return 1;
    99         else if (highway.equals("track") || highway.equals("service"))
     99        else if ("track".equals(highway) || "service".equals(highway))
    100100            return 2;
    101         else if (highway.equals("unclassified") || highway.equals("residential"))
     101        else if ("unclassified".equals(highway) || "residential".equals(highway))
    102102            return 3;
    103         else if (highway.equals("tertiary") || highway.equals("tertiary_link"))
     103        else if ("tertiary".equals(highway) || "tertiary_link".equals(highway))
    104104            return 4;
    105         else if (highway.equals("secondary") || highway.equals("secondary_link"))
     105        else if ("secondary".equals(highway) || "secondary_link".equals(highway))
    106106            return 5;
    107         else if (highway.equals("primary") || highway.equals("primary_link"))
     107        else if ("primary".equals(highway) || "primary_link".equals(highway))
    108108            return 6;
    109         else if (highway.equals("trunk") || highway.equals("trunk_link") || highway.equals("motorway") || highway.equals("motorway_link"))
     109        else if ("trunk".equals(highway) || "trunk_link".equals(highway) || "motorway".equals(highway) || "motorway_link".equals(highway))
    110110            return 7;
    111111        return 0;
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectWayNodesAction.java

    r35468 r35476  
    4141        Set<Node> selectedNodes = new LinkedHashSet<>();
    4242
    43         for (OsmPrimitive p : getLayerManager().getEditDataSet().getSelected()) {
     43        for (OsmPrimitive p : getLayerManager().getActiveDataSet().getSelected()) {
    4444            if (p instanceof Way) {
    4545                Way w = (Way) p;
     
    5656        }
    5757
    58         getLayerManager().getEditDataSet().setSelected(selectedNodes);
     58        getLayerManager().getActiveDataSet().setSelected(selectedNodes);
    5959    }
    6060
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java

    r34932 r35476  
    3030    }
    3131
    32     private Collection<OsmPrimitive> lastSel;
     32    private transient Collection<OsmPrimitive> lastSel;
    3333    private int index;
    3434
    3535    @Override
    3636    public void actionPerformed(ActionEvent e) {
    37         DataSet ds = getLayerManager().getEditDataSet();
     37        DataSet ds = getLayerManager().getActiveDataSet();
    3838        if (ds != null) {
    3939            LinkedList<Collection<? extends OsmPrimitive>> history = ds.getSelectionHistory();
     
    7878    @Override
    7979    protected void updateEnabledState() {
    80         DataSet ds = getLayerManager().getEditDataSet();
    8180        lastSel = null;
    8281        index = -1;
    83         setEnabled(ds != null && ds.getSelectionHistory().isEmpty());
     82        setEnabled(getLayerManager().getActiveDataSet() != null);
     83    }
     84
     85    @Override
     86    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
     87        setEnabled(getLayerManager().getActiveDataSet() != null);
    8488    }
    8589}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UnselectNodesAction.java

    r34812 r35476  
    3131    @Override
    3232    public void actionPerformed(ActionEvent e) {
    33         getLayerManager().getEditDataSet().clearSelection(getLayerManager().getEditDataSet().getSelectedNodes());
     33        getLayerManager().getActiveDataSet().clearSelection(getLayerManager().getActiveDataSet().getSelectedNodes());
    3434    }
    3535
Note: See TracChangeset for help on using the changeset viewer.