01: /*
02: * Project: AMODA - Abstract Modeled Application
03: * Class: de.gulden.framework.amoda.environment.gui.behaviour.CommandShowHelp
04: * Version: snapshot-beautyj-1.1
05: *
06: * Date: 2004-09-29
07: *
08: * This is a snapshot version of the AMODA 0.2 development branch,
09: * it is not released as a seperate version.
10: * For AMODA, see http://amoda.berlios.de/.
11: *
12: * This is licensed under the GNU Lesser General Public License (LGPL)
13: * and comes with NO WARRANTY.
14: *
15: * Author: Jens Gulden
16: * Email: amoda@jensgulden.de
17: */
18:
19: package de.gulden.framework.amoda.environment.gui.behaviour;
20:
21: import de.gulden.framework.amoda.generic.behaviour.GenericCommand;
22: import java.util.*;
23: import javax.help.*;
24:
25: /**
26: * Class CommandShowHelp.
27: *
28: * @author Jens Gulden
29: * @version snapshot-beautyj-1.1
30: */
31: public class CommandShowHelp extends GenericCommand {
32:
33: // ------------------------------------------------------------------------
34: // --- field ---
35: // ------------------------------------------------------------------------
36:
37: protected HelpBroker helpBroker;
38:
39: // ------------------------------------------------------------------------
40: // --- method ---
41: // ------------------------------------------------------------------------
42:
43: public void perform() {
44: if (helpBroker == null) {
45: try {
46: ClassLoader cl = getClass().getClassLoader();
47: String helpResource = getApplication().getOptions()
48: .getString("helpsystem-resource");
49: java.net.URL resource = cl
50: .getSystemResource(helpResource);
51: javax.help.HelpSet hs = new javax.help.HelpSet(cl,
52: resource);
53: helpBroker = hs.createHelpBroker();
54: helpBroker.initPresentation();
55: helpBroker.setSize(new java.awt.Dimension(800, 600));
56: java.awt.Dimension screen = (new javax.swing.JPanel())
57: .getToolkit().getScreenSize();
58: java.awt.Dimension comp = helpBroker.getSize();
59: java.awt.Point newLocation = new java.awt.Point(
60: (screen.width - comp.width) / 2,
61: (screen.height - comp.height) / 2);
62: helpBroker.setLocation(newLocation);
63:
64: /*java.awt.Frame f=findHelpFrame();
65: if (f!=null) { // if on some os the Frame can't be found by title
66: try {
67: URL u=cl.getResource("toolbarButtonGraphics/general/Information16.gif");
68: // getImage would fail without throwing anything (but failing!!), so test if URL exists
69: InputStream in=u.openStream(); // will throw exception if doesn't exist
70: in.close();
71: f.setIconImage(f.getToolkit().getImage(u));
72: } catch (Throwable t) {
73: //nop
74: }
75: }*/
76: } catch (Exception e) {
77: getApplication().error("Sorry, cannot show help.", e);
78: return;
79: }
80: }
81: helpBroker.setDisplayed(true);
82:
83: /*private static Frame findHelpFrame() {
84: java.awt.Frame[] f=Frame.getFrames();
85: for (int i=0;i<f.length;i++) {
86: if (f[i].getTitle().equals(TITLE)) { // found
87: return f[i];
88: }
89: }
90: return null; // not found (shouldn't happened if reached here)
91: }*/
92: }
93:
94: } // end CommandShowHelp
|