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

Last change on this file since 6437 was 6362, checked in by Don-vip, 11 years ago

Checkstyle:

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