1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
10 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSearchDialog;
|
---|
11 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * The tagging presets search action (F3).
|
---|
15 | * @since 3388
|
---|
16 | * @since 12834 (moved from {@code gui.tagging.presets} package)
|
---|
17 | */
|
---|
18 | public class TaggingPresetSearchAction extends JosmAction {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Constructs a new {@code TaggingPresetSearchAction}.
|
---|
22 | */
|
---|
23 | public TaggingPresetSearchAction() {
|
---|
24 | super(tr("Search preset..."), "dialogs/search", tr("Show preset search dialog"),
|
---|
25 | Shortcut.registerShortcut("preset:search", tr("Presets: {0}", tr("Search preset...")), KeyEvent.VK_F3, Shortcut.DIRECT), false);
|
---|
26 | setToolbarId("presets/search");
|
---|
27 | MainApplication.getToolbar().register(this);
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public void actionPerformed(ActionEvent e) {
|
---|
32 | if (hasActiveDataLayer()) {
|
---|
33 | TaggingPresetSearchDialog.getInstance().showDialog();
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | protected boolean listenToSelectionChange() {
|
---|
39 | return false;
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | protected void updateEnabledState() {
|
---|
44 | setEnabled(hasActiveDataLayer());
|
---|
45 | }
|
---|
46 |
|
---|
47 | private boolean hasActiveDataLayer() {
|
---|
48 | return getLayerManager().getActiveData() != null;
|
---|
49 | }
|
---|
50 | }
|
---|