| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 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.data.osm.IPrimitive;
|
|---|
| 11 | import org.openstreetmap.josm.data.osm.OsmData;
|
|---|
| 12 | import org.openstreetmap.josm.tools.Shortcut;
|
|---|
| 13 |
|
|---|
| 14 | /**
|
|---|
| 15 | * User action to select all primitives in the current dataset.
|
|---|
| 16 | */
|
|---|
| 17 | public class SelectAllAction extends JosmAction {
|
|---|
| 18 |
|
|---|
| 19 | /**
|
|---|
| 20 | * Constructs a new {@code SelectAllAction}.
|
|---|
| 21 | */
|
|---|
| 22 | public SelectAllAction() {
|
|---|
| 23 | super(tr("Select All"), "selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."),
|
|---|
| 24 | Shortcut.registerShortcut("system:selectall", tr("Selection: {0}", tr("Select All")), KeyEvent.VK_A, Shortcut.CTRL), true);
|
|---|
| 25 | setHelpId(ht("/Action/SelectAll"));
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | @Override
|
|---|
| 29 | public void actionPerformed(ActionEvent e) {
|
|---|
| 30 | if (!isEnabled())
|
|---|
| 31 | return;
|
|---|
| 32 | OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData();
|
|---|
| 33 | ds.setSelected(ds.getPrimitives(IPrimitive::isSelectable));
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | @Override
|
|---|
| 37 | protected boolean listenToSelectionChange() {
|
|---|
| 38 | return false;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | /**
|
|---|
| 42 | * Refreshes the enabled state
|
|---|
| 43 | */
|
|---|
| 44 | @Override
|
|---|
| 45 | protected void updateEnabledState() {
|
|---|
| 46 | setEnabled(getLayerManager().getActiveData() != null);
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|