source: josm/trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchDialog.java@ 12042

Last change on this file since 12042 was 10590, checked in by Don-vip, 8 years ago

see #11390, fix #13191 - Documentation and migration to java 8 of preset code (patch by michael2402) - gsoc-core

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.tagging.presets;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7
8import org.openstreetmap.josm.Main;
9import org.openstreetmap.josm.data.osm.DataSet;
10import org.openstreetmap.josm.gui.ExtendedDialog;
11
12/**
13 * The tagging presets search dialog (F3).
14 * @since 3388
15 */
16public final class TaggingPresetSearchDialog extends ExtendedDialog {
17
18 private static TaggingPresetSearchDialog instance;
19
20 private final TaggingPresetSelector selector;
21
22 /**
23 * Returns the unique instance of {@code TaggingPresetSearchDialog}.
24 * @return the unique instance of {@code TaggingPresetSearchDialog}.
25 */
26 public static synchronized TaggingPresetSearchDialog getInstance() {
27 if (instance == null) {
28 instance = new TaggingPresetSearchDialog();
29 }
30 return instance;
31 }
32
33 private TaggingPresetSearchDialog() {
34 super(Main.parent, tr("Presets"), new String[] {tr("Select"), tr("Cancel")});
35 selector = new TaggingPresetSelector(true, true);
36 setContent(selector, false);
37 DataSet.addSelectionListener(selector);
38 selector.setDblClickListener(e -> buttonAction(0, null));
39 }
40
41 @Override
42 public ExtendedDialog showDialog() {
43 selector.init();
44 super.showDialog();
45 selector.clearSelection();
46 return this;
47 }
48
49 @Override
50 protected void buttonAction(int buttonIndex, ActionEvent evt) {
51 super.buttonAction(buttonIndex, evt);
52 if (buttonIndex == 0) {
53 TaggingPreset preset = selector.getSelectedPresetAndUpdateClassification();
54 if (preset != null) {
55 preset.actionPerformed(null);
56 }
57 }
58 selector.savePreferences();
59 }
60}
Note: See TracBrowser for help on using the repository browser.