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

Last change on this file since 2323 was 2323, checked in by Gubaer, 14 years ago

Added explicit help topics
See also current list of help topics with links to source files and to help pages

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
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.HelpBrowserProxy;
15import org.openstreetmap.josm.gui.help.HelpUtil;
16import org.openstreetmap.josm.tools.ImageProvider;
17
18/**
19 * Open a help browser and displays lightweight online help.
20 *
21 */
22public class HelpAction extends AbstractAction {
23
24 public HelpAction() {
25 super(tr("Help"), ImageProvider.get("help"));
26 }
27
28 public void actionPerformed(ActionEvent e) {
29 if (e.getActionCommand() == null) {
30 String topic = null;
31 if (e.getSource() instanceof Component) {
32 Component c = SwingUtilities.getRoot((Component)e.getSource());
33 Point mouse = c.getMousePosition();
34 if (mouse != null) {
35 c = SwingUtilities.getDeepestComponentAt(c, mouse.x, mouse.y);
36 topic = HelpUtil.getContextSpecificHelpTopic(c);
37 System.out.println("topic is:" + topic);
38 } else {
39 topic = null;
40 }
41 } else {
42 Point mouse = Main.parent.getMousePosition();
43 topic = HelpUtil.getContextSpecificHelpTopic(SwingUtilities.getDeepestComponentAt(Main.parent, mouse.x, mouse.y));
44 System.out.println("topic is:" + topic);
45 }
46 if (topic == null) {
47 HelpBrowserProxy.getInstance().setUrlForHelpTopic("/");
48 } else {
49 HelpBrowserProxy.getInstance().setUrlForHelpTopic(topic);
50 }
51 } else {
52 HelpBrowserProxy.getInstance().setUrlForHelpTopic("/");
53 }
54 }
55}
Note: See TracBrowser for help on using the repository browser.