| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.gui.dialogs.relation.actions;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 5 |
|
|---|
| 6 | import java.awt.event.ActionEvent;
|
|---|
| 7 |
|
|---|
| 8 | import org.openstreetmap.josm.data.osm.Relation;
|
|---|
| 9 | import org.openstreetmap.josm.tools.ImageProvider;
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * Select the currently edited relation.
|
|---|
| 13 | * @since 12933
|
|---|
| 14 | */
|
|---|
| 15 | public class SelectAction extends AbstractRelationEditorAction {
|
|---|
| 16 | private static final long serialVersionUID = 1L;
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * Constructs a new {@code SelectAction}.
|
|---|
| 20 | * @param editorAccess An interface to access the relation editor contents.
|
|---|
| 21 | */
|
|---|
| 22 | public SelectAction(IRelationEditorActionAccess editorAccess) {
|
|---|
| 23 | super(editorAccess, IRelationEditorUpdateOn.TAG_CHANGE);
|
|---|
| 24 | putValue(NAME, tr("Select"));
|
|---|
| 25 | putValue(SHORT_DESCRIPTION, tr("Select the currently edited relation"));
|
|---|
| 26 | new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
|
|---|
| 27 | updateEnabledState();
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | @Override
|
|---|
| 31 | public void actionPerformed(ActionEvent e) {
|
|---|
| 32 | Relation toSelect = editorAccess.getEditor().getRelation();
|
|---|
| 33 | if (toSelect == null)
|
|---|
| 34 | return;
|
|---|
| 35 | getLayer().data.setSelected(toSelect);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | @Override
|
|---|
| 39 | protected void updateEnabledState() {
|
|---|
| 40 | setEnabled(editorAccess.getEditor().getRelationSnapshot() != null);
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|