source: josm/trunk/src/org/openstreetmap/josm/actions/HelpAction.java@ 7531

Last change on this file since 7531 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.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Component;
7import java.awt.Point;
8import java.awt.event.ActionEvent;
9
10import javax.swing.AbstractAction;
11import javax.swing.SwingUtilities;
12
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.gui.help.HelpBrowser;
15import org.openstreetmap.josm.gui.help.HelpUtil;
16import org.openstreetmap.josm.io.OnlineResource;
17import org.openstreetmap.josm.tools.ImageProvider;
18
19/**
20 * Open a help browser and displays lightweight online help.
21 * @since 155
22 */
23public class HelpAction extends AbstractAction {
24
25 /**
26 * Constructs a new {@code HelpAction}.
27 */
28 public HelpAction() {
29 super(tr("Help"), ImageProvider.get("help"));
30 putValue("toolbar", "help");
31 setEnabled(!Main.isOffline(OnlineResource.JOSM_WEBSITE));
32 }
33
34 @Override
35 public void actionPerformed(ActionEvent e) {
36 if (e.getActionCommand() == null) {
37 String topic;
38 if (e.getSource() instanceof Component) {
39 Component c = SwingUtilities.getRoot((Component)e.getSource());
40 Point mouse = c.getMousePosition();
41 if (mouse != null) {
42 c = SwingUtilities.getDeepestComponentAt(c, mouse.x, mouse.y);
43 topic = HelpUtil.getContextSpecificHelpTopic(c);
44 } else {
45 topic = null;
46 }
47 } else {
48 Point mouse = Main.parent.getMousePosition();
49 topic = HelpUtil.getContextSpecificHelpTopic(SwingUtilities.getDeepestComponentAt(Main.parent, mouse.x, mouse.y));
50 }
51 if (topic == null) {
52 HelpBrowser.setUrlForHelpTopic("/");
53 } else {
54 HelpBrowser.setUrlForHelpTopic(topic);
55 }
56 } else {
57 HelpBrowser.setUrlForHelpTopic("/");
58 }
59 }
60}
Note: See TracBrowser for help on using the repository browser.