1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
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.Main;
|
---|
11 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
12 |
|
---|
13 | public class UnselectAllAction extends JosmAction {
|
---|
14 |
|
---|
15 | public UnselectAllAction() {
|
---|
16 | super(tr("Unselect All"), "unselectall", tr("Unselect all objects."),
|
---|
17 | Shortcut.registerShortcut("edit:unselectall", tr("Edit: {0}", tr("Unselect All")), KeyEvent.VK_U, Shortcut.GROUP_EDIT), true);
|
---|
18 | // this is not really GROUP_EDIT, but users really would complain if the yhad to reconfigure because we put
|
---|
19 | // the correct group in
|
---|
20 |
|
---|
21 | // Add extra shortcut C-S-a
|
---|
22 | Main.registerActionShortcut(this, Shortcut.registerShortcut("edit:unselectallfocus", tr("Edit: {0}", tr("Unselect All (Focus)")),
|
---|
23 | KeyEvent.VK_A, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT));
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 | // Add extra shortcut ESCAPE
|
---|
28 | /*
|
---|
29 | * FIXME: this isn't optimal. In a better world the mapmode actions
|
---|
30 | * would be able to capture keyboard events and react accordingly. But
|
---|
31 | * for now this is a reasonable approximation.
|
---|
32 | */
|
---|
33 | Main.registerActionShortcut(this, Shortcut.registerShortcut("edit:unselectallescape", tr("Edit: {0}", tr("Unselect All (Escape)")),
|
---|
34 | KeyEvent.VK_ESCAPE, Shortcut.GROUP_DIRECT));
|
---|
35 |
|
---|
36 | putValue("help", ht("/Action/UnselectAll"));
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void actionPerformed(ActionEvent e) {
|
---|
40 | if (!isEnabled())
|
---|
41 | return;
|
---|
42 | getCurrentDataSet().setSelected();
|
---|
43 | }
|
---|
44 | /**
|
---|
45 | * Refreshes the enabled state
|
---|
46 | *
|
---|
47 | */
|
---|
48 | @Override
|
---|
49 | protected void updateEnabledState() {
|
---|
50 | setEnabled(getEditLayer() != null);
|
---|
51 | }
|
---|
52 | }
|
---|