KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > environment > gui > behaviour > CommandShowHelp


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.environment.gui.behaviour.CommandShowHelp
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * 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     // ------------------------------------------------------------------------
41
// --- method ---
42
// ------------------------------------------------------------------------
43

44     public void perform() {
45         if (helpBroker==null) {
46             try {
47                 ClassLoader JavaDoc cl=getClass().getClassLoader();
48                 String JavaDoc helpResource=getApplication().getOptions().getString("helpsystem-resource");
49                 java.net.URL JavaDoc resource=cl.getSystemResource(helpResource);
50                 javax.help.HelpSet hs=new javax.help.HelpSet(cl,resource);
51                 helpBroker=hs.createHelpBroker();
52                 helpBroker.initPresentation();
53                 helpBroker.setSize(new java.awt.Dimension JavaDoc(800,600));
54                 java.awt.Dimension JavaDoc screen=(new javax.swing.JPanel JavaDoc()).getToolkit().getScreenSize();
55                 java.awt.Dimension JavaDoc comp=helpBroker.getSize();
56                 java.awt.Point JavaDoc newLocation=new java.awt.Point JavaDoc((screen.width-comp.width)/2,(screen.height-comp.height)/2);
57                 helpBroker.setLocation(newLocation);
58
59                 /*java.awt.Frame f=findHelpFrame();
60                 if (f!=null) { // if on some os the Frame can't be found by title
61                     try {
62                         URL u=cl.getResource("toolbarButtonGraphics/general/Information16.gif");
63                         // getImage would fail without throwing anything (but failing!!), so test if URL exists
64                         InputStream in=u.openStream(); // will throw exception if doesn't exist
65                         in.close();
66                         f.setIconImage(f.getToolkit().getImage(u));
67                     } catch (Throwable t) {
68                         //nop
69                     }
70                 }*/

71             } catch (Exception JavaDoc e) {
72                 getApplication().error("Sorry, cannot show help.",e);
73                 return;
74             }
75         }
76         helpBroker.setDisplayed(true);
77
78         /*private static Frame findHelpFrame() {
79             java.awt.Frame[] f=Frame.getFrames();
80             for (int i=0;i<f.length;i++) {
81                 if (f[i].getTitle().equals(TITLE)) { // found
82                     return f[i];
83                 }
84             }
85             return null; // not found (shouldn't happened if reached here)
86         }*/

87     }
88
89 } // end CommandShowHelp
90
Popular Tags