source: josm/trunk/src/org/openstreetmap/josm/actions/InvertSelectionAction.java

Last change on this file was 19519, checked in by stoecker, 3 months ago

unify eol-style

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
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;
9
10import org.openstreetmap.josm.data.osm.OsmData;
11import org.openstreetmap.josm.tools.Shortcut;
12
13/**
14 * User action to invert the selection in the current dataset.
15 */
16public class InvertSelectionAction extends JosmAction {
17
18 /**
19 * Constructs a new {@code SelectAllAction}.
20 */
21 public InvertSelectionAction() {
22 super(tr("Invert Selection"), "invert_selection", tr("Invert Selection"),
23 Shortcut.registerShortcut("selection:invertselection",
24 tr("Selection: {0}", tr("Invert Selection")), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), true);
25 setHelpId(ht("/Action/InvertSelection"));
26 }
27
28 @Override
29 public void actionPerformed(ActionEvent e) {
30 if (!isEnabled())
31 return;
32 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData();
33 ds.setSelected(ds.getPrimitives(t -> !t.isSelected()));
34 }
35
36 @Override
37 protected boolean listenToSelectionChange() {
38 return false;
39 }
40
41 @Override
42 protected void updateEnabledState() {
43 setEnabled(getLayerManager().getActiveData() != null);
44 }
45}
Note: See TracBrowser for help on using the repository browser.