| 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("Selection: {0}",
|
|---|
| 23 | tr("Unselect All")), KeyEvent.VK_ESCAPE, Shortcut.DIRECT), true);
|
|---|
| 24 |
|
|---|
| 25 | setHelpId(ht("/Action/UnselectAll"));
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | @Override
|
|---|
| 29 | public void actionPerformed(ActionEvent e) {
|
|---|
| 30 | if (!isEnabled())
|
|---|
| 31 | return;
|
|---|
| 32 | getLayerManager().getActiveData().setSelected();
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | @Override
|
|---|
| 36 | protected boolean listenToSelectionChange() {
|
|---|
| 37 | return false;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | /**
|
|---|
| 41 | * Refreshes the enabled state
|
|---|
| 42 | */
|
|---|
| 43 | @Override
|
|---|
| 44 | protected void updateEnabledState() {
|
|---|
| 45 | setEnabled(getLayerManager().getActiveData() != null);
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|