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

Last change on this file since 9917 was 7434, checked in by Don-vip, 10 years ago

fix #8885 (see #4614) - add offline mode with new command line argument --offline which can take one of several of these values (comma separated):

  • josm_website: to disable all accesses to JOSM website (when not cached, disables Getting Started page, help, plugin list, styles, imagery, presets, rules)
  • osm_api: to disable all accesses to OSM API (disables download, upload, changeset queries, history, user message notification)
  • all: alias to disable all values. Currently equivalent to "josm_website,osm_api"

Plus improved javadoc, fixed EDT violations, and fixed a bug with HTTP redirection sent without "Location" header

  • 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 putValue(SMALL_ICON, ImageProvider.get("help"));
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.