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

Last change on this file since 12933 was 12933, checked in by Don-vip, 2 months ago

fix #15368 - Button that selects the relation from relation editor

  • Property svn:eol-style set to native
File size: 1.4 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.gui.dialogs.relation.IRelationEditor;
10import org.openstreetmap.josm.gui.layer.OsmDataLayer;
11import org.openstreetmap.josm.tools.ImageProvider;
12
13/**
14 * Select the currently edited relation.
15 * @since 12933
16 */
17public class SelectAction extends AbstractRelationEditorAction {
18
19    /**
20     * Constructs a new {@code SelectAction}.
21     * @param layer OSM data layer
22     * @param editor relation editor
23     */
24    public SelectAction(OsmDataLayer layer, IRelationEditor editor) {
25        super(null, null, null, layer, editor);
26        putValue(NAME, tr("Select"));
27        putValue(SHORT_DESCRIPTION, tr("Select the currently edited relation"));
28        new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
29        updateEnabledState();
30    }
31
32    @Override
33    public void actionPerformed(ActionEvent e) {
34        Relation toSelect = editor.getRelation();
35        if (toSelect == null)
36            return;
37        layer.data.setSelected(toSelect);
38    }
39
40    @Override
41    protected void updateEnabledState() {
42        setEnabled(editor.getRelationSnapshot() != null);
43    }
44}
Note: See TracBrowser for help on using the repository browser.