source: osm/applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java@ 30145

Last change on this file since 30145 was 30145, checked in by donvip, 11 years ago

[josm-plugins] global replacement of Main.map.mapview.getEditLayer() by Main.main.getEditLayer() (avoids NPEs)

File size: 1.4 KB
RevLine 
[25649]1package relcontext.actions;
2
[25682]3import static org.openstreetmap.josm.tools.I18n.tr;
[25649]4import java.awt.event.ActionEvent;
5import javax.swing.AbstractAction;
6import org.openstreetmap.josm.Main;
7import org.openstreetmap.josm.data.osm.Relation;
8import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
[25682]9import org.openstreetmap.josm.tools.ImageProvider;
[25649]10import relcontext.ChosenRelation;
11import relcontext.ChosenRelationListener;
12
13/**
14 * Opens an editor for chosen relation.
15 *
16 * @author Zverik
17 */
18public class EditChosenRelationAction extends AbstractAction implements ChosenRelationListener {
[25667]19 private ChosenRelation rel;
[25649]20
[25667]21 public EditChosenRelationAction( ChosenRelation rel ) {
[25682]22 super();
23// putValue(NAME, "E");
24 putValue(SMALL_ICON, ImageProvider.get("dialogs/mappaint", "pencil"));
[25695]25 putValue(SHORT_DESCRIPTION, tr("Open relation editor for the chosen relation"));
[25667]26 this.rel = rel;
27 rel.addChosenRelationListener(this);
[25711]28 setEnabled(rel.get() != null);
[25667]29 }
[25649]30
[25667]31 public void actionPerformed( ActionEvent e ) {
[25649]32 Relation relation = rel.get();
[25667]33 if( relation == null ) return;
[30145]34 RelationEditor.getEditor(Main.main.getEditLayer(), relation, null).setVisible(true);
[25667]35 }
[25649]36
[25667]37 public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
38 setEnabled(newRelation != null);
39 }
[25649]40}
Note: See TracBrowser for help on using the repository browser.