source: osm/applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java@ 33311

Last change on this file since 33311 was 32398, checked in by donvip, 9 years ago

checkstyle

File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package relcontext.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.util.Collections;
8
9import javax.swing.AbstractAction;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.command.Command;
13import org.openstreetmap.josm.command.DeleteCommand;
14import org.openstreetmap.josm.data.osm.Relation;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17import relcontext.ChosenRelation;
18import relcontext.ChosenRelationListener;
19
20public class DeleteChosenRelationAction extends AbstractAction implements ChosenRelationListener {
21 private ChosenRelation rel;
22
23 public DeleteChosenRelationAction(ChosenRelation rel) {
24 super(tr("Delete relation"));
25 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
26 this.rel = rel;
27 rel.addChosenRelationListener(this);
28 setEnabled(rel.get() != null);
29 }
30
31 @Override
32 public void actionPerformed(ActionEvent e) {
33 Relation r = rel.get();
34 rel.clear();
35 Command c = DeleteCommand.delete(Main.getLayerManager().getEditLayer(), Collections.singleton(r), true, true);
36 if (c != null) {
37 Main.main.undoRedo.add(c);
38 }
39 }
40
41 @Override
42 public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
43 setEnabled(newRelation != null);
44 }
45}
Note: See TracBrowser for help on using the repository browser.