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 | import java.util.Collection;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Action that deletes selected objects.
|
---|
17 | * @since 770
|
---|
18 | */
|
---|
19 | public final class DeleteAction extends JosmAction {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new {@code DeleteAction}.
|
---|
23 | */
|
---|
24 | public DeleteAction() {
|
---|
25 | super(tr("Delete"), "dialogs/delete", tr("Delete selected objects."),
|
---|
26 | Shortcut.registerShortcut("system:delete", tr("Edit: {0}", tr("Delete")), KeyEvent.VK_DELETE, Shortcut.DIRECT), true);
|
---|
27 | putValue("help", ht("/Action/Delete"));
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public void actionPerformed(ActionEvent e) {
|
---|
32 | if (!isEnabled() || !Main.map.mapView.isActiveLayerVisible())
|
---|
33 | return;
|
---|
34 | org.openstreetmap.josm.actions.mapmode.DeleteAction.doActionPerformed(e);
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | protected void updateEnabledState() {
|
---|
39 | updateEnabledStateOnCurrentSelection();
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
|
---|
44 | setEnabled(selection != null && !selection.isEmpty());
|
---|
45 | }
|
---|
46 | }
|
---|