| 1 | package relcontext.actions;
|
|---|
| 2 |
|
|---|
| 3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 4 | import java.awt.event.ActionEvent;
|
|---|
| 5 | import javax.swing.AbstractAction;
|
|---|
| 6 | import org.openstreetmap.josm.Main;
|
|---|
| 7 | import org.openstreetmap.josm.data.osm.Relation;
|
|---|
| 8 | import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
|
|---|
| 9 | import org.openstreetmap.josm.tools.ImageProvider;
|
|---|
| 10 | import relcontext.ChosenRelation;
|
|---|
| 11 | import relcontext.ChosenRelationListener;
|
|---|
| 12 |
|
|---|
| 13 | /**
|
|---|
| 14 | * Opens an editor for chosen relation.
|
|---|
| 15 | *
|
|---|
| 16 | * @author Zverik
|
|---|
| 17 | */
|
|---|
| 18 | public 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.map.mapView.getEditLayer(), relation, null).setVisible(true);
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | public void chosenRelationChanged( Relation oldRelation, Relation newRelation ) {
|
|---|
| 38 | setEnabled(newRelation != null);
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|