source: josm/trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java@ 10369

Last change on this file since 10369 was 10369, checked in by stoecker, 9 years ago

see #9995 - patch by strump - improve HIDPI

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.help;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8
9import javax.swing.AbstractAction;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.io.OnlineResource;
13import org.openstreetmap.josm.tools.ImageProvider;
14
15/**
16 * This is the standard help action to be used with help buttons for
17 * context sensitive help
18 * @since 2289
19 */
20public class ContextSensitiveHelpAction extends AbstractAction {
21
22 private String helpTopic;
23
24 /**
25 * Sets the help topic.
26 *
27 * @param relativeHelpTopic the relative help topic
28 */
29 public void setHelpTopic(String relativeHelpTopic) {
30 if (relativeHelpTopic == null)
31 relativeHelpTopic = "/";
32 this.helpTopic = relativeHelpTopic;
33 }
34
35 /**
36 * Constructs a new {@code ContextSensitiveHelpAction} for the root help topic.
37 */
38 public ContextSensitiveHelpAction() {
39 this(ht("/"));
40 }
41
42 /**
43 * Constructs a new {@code ContextSensitiveHelpAction} for a given help topic.
44 * @param helpTopic The help topic
45 */
46 public ContextSensitiveHelpAction(String helpTopic) {
47 putValue(SHORT_DESCRIPTION, tr("Show help information"));
48 putValue(NAME, tr("Help"));
49 new ImageProvider("help").getResource().attachImageIcon(this);
50 this.helpTopic = helpTopic;
51 setEnabled(!Main.isOffline(OnlineResource.JOSM_WEBSITE));
52 }
53
54 @Override
55 public void actionPerformed(ActionEvent e) {
56 if (helpTopic != null) {
57 HelpBrowser.setUrlForHelpTopic(helpTopic);
58 }
59 }
60}
Note: See TracBrowser for help on using the repository browser.