KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > actions > system > ActionRefresh


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.system;
20
21 import java.awt.event.ActionEvent JavaDoc;
22 import java.awt.event.InputEvent JavaDoc;
23 import java.awt.event.KeyEvent JavaDoc;
24
25 import javax.swing.Icon JavaDoc;
26 import javax.swing.JMenuItem JavaDoc;
27 import javax.swing.KeyStroke JavaDoc;
28
29 import org.openharmonise.him.actions.*;
30 import org.openharmonise.him.context.StateHandler;
31 import org.openharmonise.vfs.*;
32 import org.openharmonise.vfs.context.*;
33 import org.openharmonise.vfs.gui.*;
34
35
36 /**
37  * Action to refresh the current collection.
38  *
39  * @author Matthew Large
40  * @version $Revision: 1.1 $
41  *
42  */

43 public class ActionRefresh extends AbstractHIMAction implements HIMAction {
44
45     /**
46      *
47      */

48     public ActionRefresh() {
49         super();
50     }
51
52     /**
53      * @param vfFile
54      */

55     public ActionRefresh(VirtualFile vfFile) {
56         super(vfFile);
57     }
58
59     /* (non-Javadoc)
60      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
61      */

62     public void actionPerformed(ActionEvent JavaDoc arg0) {
63         StateHandler.getInstance().addWait("REFRESH-ACTION");
64         try {
65             this.getLastContextDirectory().refreshChildren();
66         } catch (Exception JavaDoc e) {
67             e.printStackTrace(System.err);
68         } finally {
69             StateHandler.getInstance().removeWait("REFRESH-ACTION");
70         }
71     }
72
73     /* (non-Javadoc)
74      * @see com.simulacramedia.contentmanager.actions.CMAction#getMenuItem()
75      */

76     public JMenuItem JavaDoc getMenuItem() {
77         JMenuItem JavaDoc menuItem = super.getMenuItem();
78         menuItem.setAccelerator( KeyStroke.getKeyStroke(this.getAcceleratorKeycode(), this.getAcceleratorMask()) );
79         
80         return menuItem;
81     }
82
83     /* (non-Javadoc)
84      * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
85      */

86     public String JavaDoc getDescription() {
87         return "Refreshes the currently selected collection";
88     }
89
90     /* (non-Javadoc)
91      * @see com.simulacramedia.contentmanager.actions.CMAction#getText()
92      */

93     public String JavaDoc getText() {
94         return "Refresh";
95     }
96
97     /* (non-Javadoc)
98      * @see com.simulacramedia.contentmanager.actions.CMAction#getToolTip()
99      */

100     public String JavaDoc getToolTip() {
101         return this.getDescription();
102     }
103
104     /* (non-Javadoc)
105      * @see com.simulacramedia.contentmanager.actions.CMAction#getIcon()
106      */

107     public Icon JavaDoc getIcon() {
108         return IconManager.getInstance().getIcon("16-blank.gif");
109     }
110
111     /* (non-Javadoc)
112      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
113      */

114     public int getAcceleratorKeycode() {
115         return KeyEvent.VK_R;
116     }
117
118     /* (non-Javadoc)
119      * @see com.simulacramedia.contentmanager.actions.CMAction#getMnemonic()
120      */

121     public String JavaDoc getMnemonic() {
122         return "f";
123     }
124
125     /* (non-Javadoc)
126      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
127      */

128     public int getAcceleratorMask() {
129         return InputEvent.CTRL_MASK;
130     }
131
132 }
133
Popular Tags