KickJava   Java API By Example, From Geeks To Geeks.

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


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.Dimension JavaDoc;
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.InputEvent JavaDoc;
24 import java.awt.event.KeyEvent JavaDoc;
25 import java.net.URL JavaDoc;
26
27 import javax.help.HelpBroker;
28 import javax.help.HelpSet;
29 import javax.help.CSH;
30 import javax.swing.Icon JavaDoc;
31 import javax.swing.JMenuItem JavaDoc;
32 import javax.swing.KeyStroke JavaDoc;
33
34 import org.openharmonise.him.actions.*;
35 import org.openharmonise.vfs.*;
36 import org.openharmonise.vfs.gui.*;
37
38
39 /**
40  * Action to open the main help dialog with the keyboard shortcuts
41  * selected.
42  *
43  * @author Matthew Large
44  * @version $Revision: 1.1 $
45  *
46  */

47 public class ActionKeyboardShortcuts
48     extends AbstractHIMAction
49     implements HIMAction {
50
51     /**
52      *
53      */

54     public ActionKeyboardShortcuts() {
55         super();
56     }
57
58     /**
59      * @param vfFile
60      */

61     public ActionKeyboardShortcuts(VirtualFile vfFile) {
62         super(vfFile);
63     }
64
65     /* (non-Javadoc)
66      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
67      */

68     public void actionPerformed(ActionEvent JavaDoc arg0) {
69         // TODO Auto-generated method stub
70

71     }
72
73     /* (non-Javadoc)
74      * @see com.simulacramedia.contentmanager.actions.CMAction#getMenuItem()
75      */

76     public JMenuItem JavaDoc getMenuItem() {
77         HelpBroker hb = null;
78         try {
79            String JavaDoc helpHS = "Harmonise Information Manager.hs";
80            ClassLoader JavaDoc cl = ActionHelp.class.getClassLoader();
81             URL JavaDoc hsURL = HelpSet.findHelpSet(cl, helpHS);
82             HelpSet hs = new HelpSet(null, hsURL);
83             hs.setHomeID("Keyboard_Shortcuts");
84             hb = hs.createHelpBroker();
85             hb.setSize(new Dimension JavaDoc(740,495));
86         } catch (Exception JavaDoc ee) {
87
88         }
89         
90         JMenuItem JavaDoc menuItem = super.getMenuItem();
91         menuItem.setAccelerator( KeyStroke.getKeyStroke(this.getAcceleratorKeycode(), this.getAcceleratorMask()) );
92         try {
93             menuItem.addActionListener(new CSH.DisplayHelpFromSource( hb ));
94         } catch(NullPointerException JavaDoc npe) {
95             npe.printStackTrace(System.out);
96         }
97         return menuItem;
98     }
99
100     /* (non-Javadoc)
101      * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
102      */

103     public String JavaDoc getDescription() {
104         return "Displays a list of all the keyboard shortcuts";
105     }
106
107     /* (non-Javadoc)
108      * @see com.simulacramedia.contentmanager.actions.CMAction#getText()
109      */

110     public String JavaDoc getText() {
111         return "Keyboard shortcuts";
112     }
113
114     /* (non-Javadoc)
115      * @see com.simulacramedia.contentmanager.actions.CMAction#getToolTip()
116      */

117     public String JavaDoc getToolTip() {
118         return this.getDescription();
119     }
120
121     /* (non-Javadoc)
122      * @see com.simulacramedia.contentmanager.actions.CMAction#getIcon()
123      */

124     public Icon JavaDoc getIcon() {
125         return IconManager.getInstance().getIcon("16-blank.gif");
126     }
127
128     /* (non-Javadoc)
129      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
130      */

131     public int getAcceleratorKeycode() {
132         return KeyEvent.VK_K;
133     }
134
135     /* (non-Javadoc)
136      * @see com.simulacramedia.contentmanager.actions.CMAction#getMnemonic()
137      */

138     public String JavaDoc getMnemonic() {
139         return "K";
140     }
141
142     /* (non-Javadoc)
143      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
144      */

145     public int getAcceleratorMask() {
146         return InputEvent.CTRL_MASK;
147     }
148
149 }
150
Popular Tags