[25649] | 1 | package relcontext.actions;
|
---|
| 2 |
|
---|
[25682] | 3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
[25649] | 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;
|
---|
[25682] | 9 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
[25649] | 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 {
|
---|
[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 | }
|
---|