1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.help;
|
---|
3 |
|
---|
4 | import java.awt.event.ActionEvent;
|
---|
5 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
6 |
|
---|
7 | import javax.swing.AbstractAction;
|
---|
8 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * This is the standard help action to be used with help buttons for
|
---|
14 | * context sensitive help
|
---|
15 | *
|
---|
16 | */
|
---|
17 | public class ContextSensitiveHelpAction extends AbstractAction {
|
---|
18 |
|
---|
19 | /** the help topic */
|
---|
20 | private String helpTopic;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Sets the help topic
|
---|
24 | *
|
---|
25 | * @param relativeHelpTopic the relative help topic
|
---|
26 | */
|
---|
27 | public void setHelpTopic(String relativeHelpTopic) {
|
---|
28 | if (relativeHelpTopic == null)
|
---|
29 | relativeHelpTopic = "/";
|
---|
30 | this.helpTopic = relativeHelpTopic;
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Creates a help topic for the root help topic
|
---|
35 | *
|
---|
36 | */
|
---|
37 | public ContextSensitiveHelpAction() {
|
---|
38 | this(ht("/"));
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | *
|
---|
43 | * @param helpTopic
|
---|
44 | */
|
---|
45 | public ContextSensitiveHelpAction(String helpTopic) {
|
---|
46 | putValue(SHORT_DESCRIPTION, tr("Show help information"));
|
---|
47 | putValue(NAME, tr("Help"));
|
---|
48 | putValue(SMALL_ICON, ImageProvider.get("help"));
|
---|
49 | this.helpTopic = helpTopic;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public void actionPerformed(ActionEvent e) {
|
---|
53 | if (helpTopic != null) {
|
---|
54 | HelpBrowser.setUrlForHelpTopic(helpTopic);
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|