| [32395] | 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| [25649] | 2 | package relcontext.actions;
|
|---|
| 3 |
|
|---|
| [25682] | 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| [32395] | 5 |
|
|---|
| [25649] | 6 | import java.awt.event.ActionEvent;
|
|---|
| [32395] | 7 |
|
|---|
| [25649] | 8 | import javax.swing.AbstractAction;
|
|---|
| [32395] | 9 |
|
|---|
| [25649] | 10 | import org.openstreetmap.josm.data.osm.Relation;
|
|---|
| [33530] | 11 | import org.openstreetmap.josm.gui.MainApplication;
|
|---|
| [25649] | 12 | import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
|
|---|
| [25682] | 13 | import org.openstreetmap.josm.tools.ImageProvider;
|
|---|
| [32395] | 14 |
|
|---|
| [25649] | 15 | import relcontext.ChosenRelation;
|
|---|
| 16 | import relcontext.ChosenRelationListener;
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * Opens an editor for chosen relation.
|
|---|
| [32395] | 20 | *
|
|---|
| [25649] | 21 | * @author Zverik
|
|---|
| 22 | */
|
|---|
| 23 | public class EditChosenRelationAction extends AbstractAction implements ChosenRelationListener {
|
|---|
| [36102] | 24 | private final ChosenRelation rel;
|
|---|
| [25649] | 25 |
|
|---|
| [32395] | 26 | public EditChosenRelationAction(ChosenRelation rel) {
|
|---|
| [35529] | 27 | putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit", ImageProvider.ImageSizes.SMALLICON));
|
|---|
| [25695] | 28 | putValue(SHORT_DESCRIPTION, tr("Open relation editor for the chosen relation"));
|
|---|
| [25667] | 29 | this.rel = rel;
|
|---|
| 30 | rel.addChosenRelationListener(this);
|
|---|
| [25711] | 31 | setEnabled(rel.get() != null);
|
|---|
| [25667] | 32 | }
|
|---|
| [25649] | 33 |
|
|---|
| [32395] | 34 | @Override
|
|---|
| 35 | public void actionPerformed(ActionEvent e) {
|
|---|
| [25649] | 36 | Relation relation = rel.get();
|
|---|
| [32398] | 37 | if (relation == null) return;
|
|---|
| [33530] | 38 | RelationEditor.getEditor(MainApplication.getLayerManager().getEditLayer(), relation, null).setVisible(true);
|
|---|
| [25667] | 39 | }
|
|---|
| [25649] | 40 |
|
|---|
| [32395] | 41 | @Override
|
|---|
| 42 | public void chosenRelationChanged(Relation oldRelation, Relation newRelation) {
|
|---|
| [25667] | 43 | setEnabled(newRelation != null);
|
|---|
| 44 | }
|
|---|
| [25649] | 45 | }
|
|---|