source: josm/trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java@ 6336

Last change on this file since 6336 was 6336, checked in by Don-vip, 10 years ago

code cleanup / robustness in edit layer handling

File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.relation;
3
4import java.awt.event.ActionEvent;
5
6import org.openstreetmap.josm.Main;
7import org.openstreetmap.josm.data.osm.Relation;
8import org.openstreetmap.josm.tools.ImageProvider;
9
10import static org.openstreetmap.josm.tools.I18n.tr;
11
12
13/**
14 * Action that delete relations
15 * @since 5799
16 */
17public 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
Note: See TracBrowser for help on using the repository browser.