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

Last change on this file since 30701 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
Line 
1package relcontext.actions;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
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;
9import org.openstreetmap.josm.tools.ImageProvider;
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 {
19 private ChosenRelation rel;
20
21 public EditChosenRelationAction( ChosenRelation rel ) {
22 super();
23// putValue(NAME, "E");
24 putValue(SMALL_ICON, ImageProvider.get("dialogs/mappaint", "pencil"));
25 putValue(SHORT_DESCRIPTION, tr("Open relation editor for the chosen relation"));
26 this.rel = rel;
27 rel.addChosenRelationListener(this);
28 setEnabled(rel.get() != null);
29 }
30
31 public void actionPerformed( ActionEvent e ) {
32 Relation relation = rel.get();
33 if( relation == null ) return;
34 RelationEditor.getEditor(Main.main.getEditLayer(), relation, null).setVisible(true);
35 }
36
37 public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
38 setEnabled(newRelation != null);
39 }
40}
Note: See TracBrowser for help on using the repository browser.