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.DataSet;
|
---|
11 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
12 |
|
---|
13 | public class SelectAllAction extends JosmAction {
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Constructs a new {@code SelectAllAction}.
|
---|
17 | */
|
---|
18 | public SelectAllAction() {
|
---|
19 | super(tr("Select All"), "selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."),
|
---|
20 | Shortcut.registerShortcut("system:selectall", tr("Edit: {0}", tr("Select All")), KeyEvent.VK_A, Shortcut.CTRL), true);
|
---|
21 | putValue("help", ht("/Action/SelectAll"));
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public void actionPerformed(ActionEvent e) {
|
---|
26 | if (!isEnabled())
|
---|
27 | return;
|
---|
28 | DataSet ds = getLayerManager().getEditDataSet();
|
---|
29 | ds.setSelected(ds.allNonDeletedCompletePrimitives());
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Refreshes the enabled state
|
---|
34 | *
|
---|
35 | */
|
---|
36 | @Override
|
---|
37 | protected void updateEnabledState() {
|
---|
38 | setEnabled(getLayerManager().getEditLayer() != null);
|
---|
39 | }
|
---|
40 | }
|
---|