1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 | import javax.swing.KeyStroke;
|
---|
9 | import javax.swing.JComponent;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.tools.ShortCut;
|
---|
13 |
|
---|
14 | public class UnselectAllAction extends JosmAction {
|
---|
15 |
|
---|
16 | public UnselectAllAction() {
|
---|
17 | super(tr("Unselect All"), "unselectall", tr("Unselect all objects."),
|
---|
18 | ShortCut.registerShortCut("edit:unselectall", tr("Edit: Unselect all"), KeyEvent.VK_U, ShortCut.GROUP_EDIT), true);
|
---|
19 | // this is not really GROUP_EDIT, but users really would complain if the yhad to reconfigure because we put
|
---|
20 | // the correct group in
|
---|
21 |
|
---|
22 | // Add extra shortcut C-S-a
|
---|
23 | Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
---|
24 | ShortCut.registerShortCut("edit:unselectall2", tr("Edit: Unselect all (2)"), KeyEvent.VK_A, ShortCut.GROUP_MENU).getKeyStroke(),
|
---|
25 | tr("Unselect All"));
|
---|
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.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
|
---|
34 | ShortCut.registerShortCut("edit:unselectall3", tr("Edit: Unselect all (3)"), KeyEvent.VK_ESCAPE, ShortCut.GROUP_DIRECT).getKeyStroke(),
|
---|
35 | tr("Unselect All"));
|
---|
36 | }
|
---|
37 |
|
---|
38 | public void actionPerformed(ActionEvent e) {
|
---|
39 | Main.ds.setSelected();
|
---|
40 | }
|
---|
41 | }
|
---|