KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > actions > help > ActionHelp


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.actions.help;
20
21 import java.awt.*;
22 import java.awt.event.*;
23 import java.net.*;
24
25 import javax.help.*;
26 import javax.swing.*;
27
28 import org.openharmonise.him.actions.*;
29 import org.openharmonise.vfs.*;
30 import org.openharmonise.vfs.gui.*;
31
32
33 /**
34  * Action to open the main help dialog.
35  *
36  * @author Matthew Large
37  * @version $Revision: 1.1 $
38  *
39  */

40 public class ActionHelp extends AbstractHIMAction implements HIMAction {
41
42     /**
43      *
44      */

45     public ActionHelp() {
46         super();
47     }
48
49     /**
50      * @param vfFile
51      */

52     public ActionHelp(VirtualFile vfFile) {
53         super(vfFile);
54     }
55
56     /* (non-Javadoc)
57      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
58      */

59     public void actionPerformed(ActionEvent arg0) {
60
61     }
62
63     /* (non-Javadoc)
64      * @see com.simulacramedia.contentmanager.actions.CMAction#getMenuItem()
65      */

66     public JMenuItem getMenuItem() {
67         HelpBroker hb = null;
68         try {
69            String JavaDoc helpHS = "Harmonise Information Manager.hs";
70            ClassLoader JavaDoc cl = ActionHelp.class.getClassLoader();
71             URL hsURL = HelpSet.findHelpSet(cl, helpHS);
72             HelpSet hs = new HelpSet(null, hsURL);
73             hb = hs.createHelpBroker();
74             hb.setSize(new Dimension(740,495));
75         } catch (Exception JavaDoc ee) {
76
77         }
78         
79         JMenuItem menuItem = super.getMenuItem();
80         menuItem.setAccelerator( KeyStroke.getKeyStroke(this.getAcceleratorKeycode(), this.getAcceleratorMask()) );
81         try {
82             menuItem.addActionListener(new CSH.DisplayHelpFromSource( hb ));
83         } catch(NullPointerException JavaDoc npe) {
84             npe.printStackTrace(System.out);
85         }
86         return menuItem;
87     }
88
89     /* (non-Javadoc)
90      * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
91      */

92     public String JavaDoc getDescription() {
93         return "Displays the help system";
94     }
95
96     /* (non-Javadoc)
97      * @see com.simulacramedia.contentmanager.actions.CMAction#getText()
98      */

99     public String JavaDoc getText() {
100         return "Help";
101     }
102
103     /* (non-Javadoc)
104      * @see com.simulacramedia.contentmanager.actions.CMAction#getToolTip()
105      */

106     public String JavaDoc getToolTip() {
107         return this.getDescription();
108     }
109
110     /* (non-Javadoc)
111      * @see com.simulacramedia.contentmanager.actions.CMAction#getIcon()
112      */

113     public Icon getIcon() {
114         return IconManager.getInstance().getIcon("16-command-help.gif");
115     }
116
117     /* (non-Javadoc)
118      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
119      */

120     public int getAcceleratorKeycode() {
121         return KeyEvent.VK_F1;
122     }
123
124     /* (non-Javadoc)
125      * @see com.simulacramedia.contentmanager.actions.CMAction#getMnemonic()
126      */

127     public String JavaDoc getMnemonic() {
128         return "H";
129     }
130
131     /* (non-Javadoc)
132      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
133      */

134     public int getAcceleratorMask() {
135         return 0;
136     }
137
138 }
139
Popular Tags