1 | package org.openstreetmap.josm.plugins.taggingpresettester;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import java.awt.event.ActionEvent;
|
---|
6 | import java.awt.event.KeyEvent;
|
---|
7 | import java.util.Collection;
|
---|
8 |
|
---|
9 | import javax.swing.JOptionPane;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
12 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
13 | import org.openstreetmap.josm.gui.MainMenu;
|
---|
14 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
|
---|
15 | import org.openstreetmap.josm.plugins.PluginInformation;
|
---|
16 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Fires up the tagging preset tester
|
---|
20 | * @author Immanuel.Scholz
|
---|
21 | */
|
---|
22 | public class TaggingPresetTesterAction extends JosmAction {
|
---|
23 |
|
---|
24 | public TaggingPresetTesterAction() {
|
---|
25 | super(tr("Tagging Preset Tester"), "tagging-preset-tester",
|
---|
26 | tr("Open the tagging preset test tool for previewing tagging preset dialogs."),
|
---|
27 | Shortcut.registerShortcut("tools:taggingpresettester",
|
---|
28 | tr("Windows: {0}", tr("Tagging Preset Tester")),
|
---|
29 | KeyEvent.VK_T, Shortcut.ALT_CTRL_SHIFT), true);
|
---|
30 | MainMenu.addAfter(MainApplication.getMenu().windowMenu, this, false, MainApplication.getMenu().changesetManager);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public TaggingPresetTesterAction(PluginInformation info) {
|
---|
34 | this();
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public void actionPerformed(ActionEvent e) {
|
---|
39 | Collection<String> coll = TaggingPresetReader.getPresetSources();
|
---|
40 |
|
---|
41 | if (coll.isEmpty()) {
|
---|
42 | JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("You have to specify tagging preset sources in the preferences first."));
|
---|
43 | return;
|
---|
44 | }
|
---|
45 |
|
---|
46 | String[] taggingPresetSources = new String [coll.size()];
|
---|
47 | coll.toArray(taggingPresetSources);
|
---|
48 | new TaggingPresetTester(taggingPresetSources).setVisible(true);
|
---|
49 | }
|
---|
50 | }
|
---|