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

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

use IRelation in RelationListDialog and *RelationActions

  • Property svn:eol-style set to native
File size: 1.8 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.actions.mapmode.DeleteAction;
10import org.openstreetmap.josm.data.osm.OsmUtils;
11import org.openstreetmap.josm.data.osm.Relation;
12import org.openstreetmap.josm.gui.MainApplication;
13import org.openstreetmap.josm.gui.MapFrame;
14import org.openstreetmap.josm.gui.layer.OsmDataLayer;
15import org.openstreetmap.josm.tools.ImageProvider;
16import org.openstreetmap.josm.tools.Utils;
17
18/**
19 * Action that delete relations
20 * @since 5799
21 */
22public class DeleteRelationsAction extends AbstractRelationAction {
23
24 /**
25 * Constructs a new <code>DeleteRelationsAction</code>.
26 */
27 public DeleteRelationsAction() {
28 putValue(SHORT_DESCRIPTION, tr("Delete the selected relation"));
29 putValue(NAME, tr("Delete"));
30 new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
31 }
32
33 protected void deleteRelation(Collection<Relation> toDelete) {
34 OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
35 if (toDelete == null || layer == null)
36 return;
37
38 DeleteAction.deleteRelations(layer, toDelete);
39 // clear selection after deletion
40 MapFrame map = MainApplication.getMap();
41 if (map.relationListDialog != null)
42 map.relationListDialog.selectRelations(null);
43 }
44
45 @Override
46 public void actionPerformed(ActionEvent e) {
47 if (!isEnabled())
48 return;
49 deleteRelation(Utils.filteredCollection(relations, Relation.class));
50 }
51
52 @Override
53 protected void updateEnabledState() {
54 setEnabled(OsmUtils.isOsmCollectionEditable(relations));
55 }
56}
Note: See TracBrowser for help on using the repository browser.