01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16 package org.qedeq.gui.se.control;
17
18 import java.awt.Dimension;
19 import java.awt.event.ActionEvent;
20 import java.net.URL;
21
22 import javax.help.HelpSet;
23 import javax.help.JHelp;
24 import javax.swing.AbstractAction;
25 import javax.swing.JDialog;
26 import javax.swing.JOptionPane;
27 import javax.swing.UIDefaults;
28 import javax.swing.UIManager;
29
30 import org.qedeq.base.io.ResourceLoaderUtility;
31 import org.qedeq.base.trace.Trace;
32 import org.qedeq.gui.se.util.ExternalLinkContentViewerUI;
33 import org.qedeq.gui.se.util.GuiHelper;
34 import org.qedeq.kernel.bo.KernelContext;
35
36 /**
37 * Show help window.
38 *
39 * @author Michael Meyling
40 */
41 class HelpAction extends AbstractAction {
42
43 /** This class. */
44 private static final Class CLASS = HelpAction.class;
45
46 /** Controller reference. */
47 private final QedeqController controller;
48
49 /**
50 * Constructor.
51 *
52 * @param controller Controller.
53 */
54 HelpAction(final QedeqController controller) {
55 this.controller = controller;
56 }
57
58 public void actionPerformed(final ActionEvent e) {
59
60 String pathToHS = "resources/help/Help.hs";
61 URL hsURL = null;
62 HelpSet hs = null;
63 try {
64 hsURL = ResourceLoaderUtility.getResourceUrl(pathToHS);
65 hs = new HelpSet(null, hsURL);
66 } catch (Exception ex) {
67 Trace.fatal(CLASS, this, "actionPerformed(ActionEvent)",
68 "Problems loading help set.", ex);
69 JOptionPane.showMessageDialog(
70 controller.getMainFrame(), "Help for "
71 + KernelContext.getInstance().getDescriptiveKernelVersion() + "\n\n"
72 + "Still missing" + "\n\n", "Help",
73 JOptionPane.INFORMATION_MESSAGE,
74 GuiHelper.readImageIcon("qedeq/32x32/qedeq.png"));
75 return;
76 }
77 // integrate native browser into JHelp
78 final UIDefaults table = UIManager.getDefaults();
79 final Object[] uiDefaults = {"HelpContentViewerUI",
80 ExternalLinkContentViewerUI.class.getName()
81 };
82 table.putDefaults(uiDefaults);
83 final JHelp jHelp = new JHelp(hs);
84 final JDialog dialog = new JDialog(controller.getMainFrame(), "Help", true);
85 dialog.getContentPane().add("Center", jHelp);
86 dialog.setSize(new Dimension(950, 700));
87 dialog.setLocationRelativeTo(null);
88 dialog.setVisible(true);
89 }
90
91 }
|