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

Last change on this file since 11063 was 10453, checked in by Don-vip, 8 years ago

fix #13023 - Replace uses of hasEditLayer() with new layer manager (patch by michael2402, modified) - gsoc-core

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions.relation;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.util.Collection;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.actions.mapmode.DeleteAction;
11import org.openstreetmap.josm.data.osm.Relation;
12import org.openstreetmap.josm.gui.layer.OsmDataLayer;
13import org.openstreetmap.josm.tools.ImageProvider;
14
15/**
16 * Action that delete relations
17 * @since 5799
18 */
19public 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}
Note: See TracBrowser for help on using the repository browser.