Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
6 |
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.osm.OsmData;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * User action to invert the selection in the current dataset.
|
---|
13 | */
|
---|
14 | public class InvertSelectionAction extends JosmAction {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Constructs a new {@code SelectAllAction}.
|
---|
18 | */
|
---|
19 | public InvertSelectionAction() {
|
---|
20 | super(tr("Invert Selection"), null, tr("Invert Selection"), null, true);
|
---|
21 | setHelpId(ht("/Action/InvertSelection"));
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public void actionPerformed(ActionEvent e) {
|
---|
26 | if (!isEnabled())
|
---|
27 | return;
|
---|
28 | OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData();
|
---|
29 | ds.setSelected(ds.getPrimitives(t -> !t.isSelected()));
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | protected boolean listenToSelectionChange() {
|
---|
34 | return false;
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | protected void updateEnabledState() {
|
---|
39 | setEnabled(getLayerManager().getActiveData() != null);
|
---|
40 | }
|
---|
41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.