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