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 |
|
---|
8 | import org.openstreetmap.josm.Main;
|
---|
9 | import org.openstreetmap.josm.data.osm.Relation;
|
---|
10 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Action that delete relations
|
---|
14 | * @since 5799
|
---|
15 | */
|
---|
16 | public class DeleteRelationsAction extends AbstractRelationAction {
|
---|
17 | static class AbortException extends Exception {}
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructs a new <code>DeleteRelationsAction</code>.
|
---|
21 | */
|
---|
22 | public DeleteRelationsAction() {
|
---|
23 | putValue(SHORT_DESCRIPTION,tr("Delete the selected relation"));
|
---|
24 | putValue(NAME, tr("Delete"));
|
---|
25 | putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
|
---|
26 | }
|
---|
27 |
|
---|
28 | protected void deleteRelation(Relation toDelete) {
|
---|
29 | if (toDelete == null)
|
---|
30 | return;
|
---|
31 | org.openstreetmap.josm.actions.mapmode.DeleteAction
|
---|
32 | .deleteRelation( Main.main.getEditLayer(), toDelete );
|
---|
33 | // clear selection after deletion
|
---|
34 | if (Main.map.relationListDialog!=null)
|
---|
35 | Main.map.relationListDialog.selectRelations(null);
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public void actionPerformed(ActionEvent e) {
|
---|
40 | if (!isEnabled() || !Main.main.hasEditLayer())
|
---|
41 | return;
|
---|
42 | for (Relation r : relations) {
|
---|
43 | deleteRelation(r);
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|