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

Last change on this file since 28813 was 28813, checked in by zverik, 12 years ago

Fix #8062

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