source: subversion/applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UnselectNodesAction.java

Last change on this file was 34812, checked in by gerdp, 3 months ago

see #17187:

  • Replace deprecated methods
  • Remove dead code
  • Make Shift+Z (Select last modified nodes) work again + Repated Shift+Z cycles through the commands available in the undo tree + Ignore changes in other layers
  • Make Alt+Shift+Z (Select last modified Ways) work again (same logic as with Shift+Z)
  • fix some javadoc errors


File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.utilsplugin2.selection;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9import java.util.Collection;
10
11import org.openstreetmap.josm.actions.JosmAction;
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.tools.Shortcut;
14
15/**
16 * Unselect all nodes.
17 */
18public class UnselectNodesAction extends JosmAction {
19
20    /**
21     * Constructs a new {@code UnselectNodesAction}.
22     */
23    public UnselectNodesAction() {
24        super(tr("Unselect nodes"), "unsnodes",
25                tr("Removes all nodes from selection"),
26                Shortcut.registerShortcut("tools:unsnodes", tr("Tool: {0}", "Unselect nodes"),
27                        KeyEvent.VK_U, Shortcut.SHIFT), true);
28        putValue("help", ht("/Action/UnselectNodes"));
29    }
30
31    @Override
32    public void actionPerformed(ActionEvent e) {
33        getLayerManager().getEditDataSet().clearSelection(getLayerManager().getEditDataSet().getSelectedNodes());
34    }
35
36    @Override
37    protected void updateEnabledState() {
38        updateEnabledStateOnCurrentSelection();
39    }
40
41    @Override
42    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
43        if (selection == null) {
44            setEnabled(false);
45            return;
46        }
47        setEnabled(!selection.isEmpty());
48    }
49}
Note: See TracBrowser for help on using the repository browser.