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 | import java.awt.event.KeyEvent;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * User action to clear the current selection.
|
---|
14 | */
|
---|
15 | public class UnselectAllAction extends JosmAction {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Constructs a new {@code UnselectAllAction}.
|
---|
19 | */
|
---|
20 | public UnselectAllAction() {
|
---|
21 | super(tr("Unselect All"), "unselectall", tr("Unselect all objects."),
|
---|
22 | Shortcut.registerShortcut("edit:unselectall", tr("Edit: {0}",
|
---|
23 | tr("Unselect All")), KeyEvent.VK_ESCAPE, Shortcut.DIRECT), true);
|
---|
24 |
|
---|
25 | putValue("help", ht("/Action/UnselectAll"));
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public void actionPerformed(ActionEvent e) {
|
---|
30 | if (!isEnabled())
|
---|
31 | return;
|
---|
32 | getLayerManager().getEditDataSet().setSelected();
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Refreshes the enabled state
|
---|
37 | */
|
---|
38 | @Override
|
---|
39 | protected void updateEnabledState() {
|
---|
40 | setEnabled(getLayerManager().getEditLayer() != null);
|
---|
41 | }
|
---|
42 | }
|
---|