1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions.relation;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.util.Collection;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.actions.mapmode.DeleteAction;
|
---|
11 | import org.openstreetmap.josm.data.osm.Relation;
|
---|
12 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
13 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Action that delete relations
|
---|
17 | * @since 5799
|
---|
18 | */
|
---|
19 | public class DeleteRelationsAction extends AbstractRelationAction {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new <code>DeleteRelationsAction</code>.
|
---|
23 | */
|
---|
24 | public DeleteRelationsAction() {
|
---|
25 | putValue(SHORT_DESCRIPTION, tr("Delete the selected relation"));
|
---|
26 | putValue(NAME, tr("Delete"));
|
---|
27 | new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
|
---|
28 | }
|
---|
29 |
|
---|
30 | protected void deleteRelation(Collection<Relation> toDelete) {
|
---|
31 | OsmDataLayer layer = Main.getLayerManager().getEditLayer();
|
---|
32 | if (toDelete == null || layer == null)
|
---|
33 | return;
|
---|
34 |
|
---|
35 | DeleteAction.deleteRelations(layer, toDelete);
|
---|
36 | // clear selection after deletion
|
---|
37 | if (Main.map.relationListDialog != null)
|
---|
38 | Main.map.relationListDialog.selectRelations(null);
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public void actionPerformed(ActionEvent e) {
|
---|
43 | if (!isEnabled())
|
---|
44 | return;
|
---|
45 | deleteRelation(relations);
|
---|
46 | }
|
---|
47 | }
|
---|