source: josm/trunk/src/org/openstreetmap/josm/actions/UnselectAllAction.java@ 2284

Last change on this file since 2284 was 1865, checked in by Gubaer, 15 years ago

replaced JOptionPane.show* by OptionPaneUtil.show*
ExtendeDialog now always on top, too

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.awt.event.KeyEvent;
8
9import javax.swing.JComponent;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.tools.Shortcut;
13
14public 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: {0}", tr("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:unselectallfocus", tr("Edit: {0}", tr("Unselect All (Focus)")),
25 KeyEvent.VK_A, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT).getKeyStroke(),
26 tr("Unselect All"));
27
28 // Add extra shortcut ESCAPE
29 /*
30 * FIXME: this isn't optimal. In a better world the mapmode actions
31 * would be able to capture keyboard events and react accordingly. But
32 * for now this is a reasonable approximation.
33 */
34 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
35 Shortcut.registerShortcut("edit:unselectallescape", tr("Edit: {0}", tr("Unselect All (Escape)")),
36 KeyEvent.VK_ESCAPE, Shortcut.GROUP_DIRECT).getKeyStroke(),
37 tr("Unselect All"));
38 }
39
40 public void actionPerformed(ActionEvent e) {
41 if (!isEnabled())
42 return;
43 getCurrentDataSet().setSelected();
44 }
45 /**
46 * Refreshes the enabled state
47 *
48 */
49 @Override
50 protected void updateEnabledState() {
51 setEnabled(getEditLayer() != null);
52 }
53}
Note: See TracBrowser for help on using the repository browser.