source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SelectAction.java @ 14027

Last change on this file since 14027 was 14027, checked in by michael2402, 5 months ago

See #16388: New mechanism for plugins to register relation editor actions.

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