source: josm/trunk/src/org/openstreetmap/josm/actions/SelectAllAction.java

Last change on this file was 17062, checked in by Klumbumbus, 4 years ago

fix #19850 - Add possibility to add a shortcut for more actions and toggle dialogs, fix shortcut display name of some selection menu entries

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import org.openstreetmap.josm.data.osm.OsmData;
11import org.openstreetmap.josm.tools.Shortcut;
12
13/**
14 * User action to select all primitives in the current dataset.
15 */
16public class SelectAllAction extends JosmAction {
17
18 /**
19 * Constructs a new {@code SelectAllAction}.
20 */
21 public SelectAllAction() {
22 super(tr("Select All"), "selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."),
23 Shortcut.registerShortcut("system:selectall", tr("Selection: {0}", tr("Select All")), KeyEvent.VK_A, Shortcut.CTRL), true);
24 setHelpId(ht("/Action/SelectAll"));
25 }
26
27 @Override
28 public void actionPerformed(ActionEvent e) {
29 if (!isEnabled())
30 return;
31 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData();
32 // Do not use method reference before the Java 11 migration
33 // Otherwise we face a compiler bug, see below:
34 // https://bugs.openjdk.java.net/browse/JDK-8141508
35 // https://bugs.openjdk.java.net/browse/JDK-8142476
36 // https://bugs.openjdk.java.net/browse/JDK-8191655
37 ds.setSelected(ds.getPrimitives(t -> t.isSelectable()));
38 }
39
40 @Override
41 protected boolean listenToSelectionChange() {
42 return false;
43 }
44
45 /**
46 * Refreshes the enabled state
47 */
48 @Override
49 protected void updateEnabledState() {
50 setEnabled(getLayerManager().getActiveData() != null);
51 }
52}
Note: See TracBrowser for help on using the repository browser.