1 | package org.openstreetmap.josm.actions;
|
---|
2 |
|
---|
3 |
|
---|
4 | import javax.swing.AbstractAction;
|
---|
5 | import javax.swing.JComponent;
|
---|
6 | import javax.swing.KeyStroke;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.Main;
|
---|
9 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Base class helper for all Actions in JOSM. Just to make the life easier.
|
---|
13 | * @author imi
|
---|
14 | */
|
---|
15 | abstract public class JosmAction extends AbstractAction {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Construct the action as menu action entry.
|
---|
19 | *
|
---|
20 | * @param name Name of the action (entry name in menu)
|
---|
21 | * @param iconName Name of the icon (without extension)
|
---|
22 | * @param tooltip Short tooltip description
|
---|
23 | * @param mnemonic Mnemonic in the menu
|
---|
24 | */
|
---|
25 | public JosmAction(String name, String iconName, String tooltip, int mnemonic) {
|
---|
26 | super(name, ImageProvider.get(iconName));
|
---|
27 | putValue(SHORT_DESCRIPTION, tooltip);
|
---|
28 | putValue(MNEMONIC_KEY, mnemonic);
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 | public JosmAction(String name, String iconName, String tooltip, String shortCutName, KeyStroke shortCut) {
|
---|
33 | super(name, ImageProvider.get(iconName));
|
---|
34 | putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+shortCutName+"</font> </html>");
|
---|
35 | //Main.panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortCut, name);
|
---|
36 | //Main.panel.getActionMap().put(name, this);
|
---|
37 | Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortCut, name);
|
---|
38 | Main.contentPane.getActionMap().put(name, this);
|
---|
39 | }
|
---|
40 |
|
---|
41 | public JosmAction() {
|
---|
42 | }
|
---|
43 | }
|
---|