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

Last change on this file since 14628 was 14397, checked in by Don-vip, 5 years ago

fix #16935 - simplify/cleanup help topics of ToggleDialog/ToggleDialogAction

  • Property svn:eol-style set to native
File size: 1.6 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("Edit: {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 /**
41 * Refreshes the enabled state
42 */
43 @Override
44 protected void updateEnabledState() {
45 setEnabled(getLayerManager().getActiveData() != null);
46 }
47}
Note: See TracBrowser for help on using the repository browser.