[6380] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[626] | 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
[8510] | 4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
[626] | 5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 6 |
|
---|
| 7 | import java.awt.event.ActionEvent;
|
---|
| 8 | import java.awt.event.KeyEvent;
|
---|
| 9 |
|
---|
[10382] | 10 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
[10711] | 11 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
[1084] | 12 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
[626] | 13 |
|
---|
[12581] | 14 | /**
|
---|
| 15 | * User action to select all primitives in the current dataset.
|
---|
| 16 | */
|
---|
[1820] | 17 | public class SelectAllAction extends JosmAction {
|
---|
[626] | 18 |
|
---|
[8510] | 19 | /**
|
---|
| 20 | * Constructs a new {@code SelectAllAction}.
|
---|
| 21 | */
|
---|
[1169] | 22 | public SelectAllAction() {
|
---|
[8510] | 23 | super(tr("Select All"), "selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."),
|
---|
[4982] | 24 | Shortcut.registerShortcut("system:selectall", tr("Edit: {0}", tr("Select All")), KeyEvent.VK_A, Shortcut.CTRL), true);
|
---|
[2323] | 25 | putValue("help", ht("/Action/SelectAll"));
|
---|
[1169] | 26 | }
|
---|
[626] | 27 |
|
---|
[6084] | 28 | @Override
|
---|
[1169] | 29 | public void actionPerformed(ActionEvent e) {
|
---|
[1808] | 30 | if (!isEnabled())
|
---|
| 31 | return;
|
---|
[13434] | 32 | DataSet ds = getLayerManager().getActiveDataSet();
|
---|
[10711] | 33 | ds.setSelected(ds.getPrimitives(OsmPrimitive::isSelectable));
|
---|
[1169] | 34 | }
|
---|
[1808] | 35 |
|
---|
| 36 | /**
|
---|
| 37 | * Refreshes the enabled state
|
---|
| 38 | */
|
---|
[1820] | 39 | @Override
|
---|
| 40 | protected void updateEnabledState() {
|
---|
[13434] | 41 | setEnabled(getLayerManager().getActiveDataSet() != null);
|
---|
[1808] | 42 | }
|
---|
[626] | 43 | }
|
---|