001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs.relation.actions; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.awt.event.ActionEvent; 007 008import org.openstreetmap.josm.data.osm.Relation; 009import org.openstreetmap.josm.tools.ImageProvider; 010 011/** 012 * Select the currently edited relation. 013 * @since 12933 014 */ 015public class SelectAction extends AbstractRelationEditorAction { 016 private static final long serialVersionUID = 1L; 017 018 /** 019 * Constructs a new {@code SelectAction}. 020 * @param editorAccess An interface to access the relation editor contents. 021 */ 022 public SelectAction(IRelationEditorActionAccess editorAccess) { 023 super(editorAccess); 024 putValue(NAME, tr("Select")); 025 putValue(SHORT_DESCRIPTION, tr("Select the currently edited relation")); 026 new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true); 027 updateEnabledState(); 028 } 029 030 @Override 031 public void actionPerformed(ActionEvent e) { 032 Relation toSelect = editorAccess.getEditor().getRelation(); 033 if (toSelect == null) 034 return; 035 getLayer().data.setSelected(toSelect); 036 } 037 038 @Override 039 protected void updateEnabledState() { 040 setEnabled(editorAccess.getEditor().getRelationSnapshot() != null); 041 } 042}