source: subversion/applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/LaunchAction.java

Last change on this file was 34560, checked in by donvip, 8 months ago

update to JOSM 14153

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.tageditor;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.awt.event.KeyEvent;
8import java.util.Set;
9
10import org.openstreetmap.josm.actions.JosmAction;
11import org.openstreetmap.josm.data.osm.DataSelectionListener;
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
14import org.openstreetmap.josm.tools.Shortcut;
15
16public class LaunchAction extends JosmAction implements DataSelectionListener {
17
18    public LaunchAction() {
19        super(
20                tr("Edit tags"),
21                (String) null, //TODO: set "tag-editor" and add /images/tag-editor.png to distrib
22                tr("Launches the tag editor dialog"),
23                Shortcut.registerShortcut("edit:launchtageditor", tr("Launches the tag editor dialog"),
24                        KeyEvent.VK_1, Shortcut.ALT_SHIFT),
25                true, "tageditor/launch", true);
26
27        SelectionEventManager.getInstance().addSelectionListener(this);
28        setEnabled(false);
29    }
30
31    /**
32     * launch the editor
33     */
34    protected void launchEditor() {
35        if (!isEnabled())
36            return;
37        TagEditorDialog dialog = TagEditorDialog.getInstance();
38        dialog.startEditSession();
39        dialog.setVisible(true);
40    }
41
42    @Override
43    public void actionPerformed(ActionEvent e) {
44        launchEditor();
45    }
46
47    @Override
48    public void selectionChanged(SelectionChangeEvent event) {
49        Set<OsmPrimitive> newSelection = event.getSelection();
50        setEnabled(newSelection != null && newSelection.size() > 0);
51    }
52}
Note: See TracBrowser for help on using the repository browser.