KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > actions > publish > ActionExport


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.publish;
20
21 import java.awt.event.*;
22
23 import javax.swing.*;
24
25 import org.openharmonise.him.actions.*;
26 import org.openharmonise.him.actions.rules.*;
27 import org.openharmonise.him.context.StateHandler;
28 import org.openharmonise.him.editors.*;
29 import org.openharmonise.him.harmonise.*;
30 import org.openharmonise.him.window.messages.builders.*;
31 import org.openharmonise.vfs.*;
32 import org.openharmonise.vfs.context.*;
33 import org.openharmonise.vfs.gui.*;
34 import org.openharmonise.vfs.status.*;
35
36
37 /**
38  * Action to export a virtual file.
39  *
40  * @author Matthew Large
41  * @version $Revision: 1.1 $
42  *
43  */

44 public class ActionExport extends AbstractHIMAction implements HIMAction {
45
46     public static String JavaDoc ACTION_NAME = "EXPORT";
47
48     /**
49      * Wait identifier for state handler.
50      */

51     private static final String JavaDoc WAIT_LABEL = "EXPORT-ACTION";
52     
53     /**
54      *
55      */

56     public ActionExport() {
57         super();
58         this.setup();
59     }
60
61     /**
62      * @param vfFile
63      */

64     public ActionExport(VirtualFile vfFile) {
65         super(vfFile);
66         this.setup();
67     }
68     
69     /**
70      * Configures this action.
71      *
72      */

73     private void setup() {
74         PathRule pathRule = new PathRule(HarmonisePaths.PATH_DOCUMENTS);
75         this.addEnableRule(pathRule);
76         pathRule = new PathRule(HarmonisePaths.PATH_IMAGES);
77         this.addEnableRule(pathRule);
78         pathRule = new PathRule(HarmonisePaths.PATH_PDF);
79         this.addEnableRule(pathRule);
80         pathRule = new PathRule(HarmonisePaths.PATH_FLASH);
81         this.addEnableRule(pathRule);
82         pathRule = new PathRule(HarmonisePaths.PATH_REPORTS_OUTPUT);
83         this.addEnableRule(pathRule);
84     }
85
86     /* (non-Javadoc)
87      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
88      */

89     public void actionPerformed(ActionEvent arg0) {
90         StatusData statusOverall = new VFSStatus();
91         VirtualFile vfFile =this.getLastContextFile();
92         StateHandler.getInstance().addWait(WAIT_LABEL);
93         String JavaDoc sFileName = vfFile.getVFS().getVirtualFileSystemView().getDisplayName(vfFile);
94         try {
95             StatusData status = EditorController.getInstance().export(vfFile.getFullPath(), this.getLastContextFile().getVFS());
96             statusOverall.addStatusData(status);
97         } catch(Exception JavaDoc e) {
98             e.printStackTrace(System.err);
99             statusOverall.setStatusLevel(StatusData.LEVEL_ERROR);
100         } finally {
101             StateHandler.getInstance().removeWait(WAIT_LABEL);
102             VFSMessageBuilder.getInstance().fireMessage(ActionExport.ACTION_NAME, statusOverall, sFileName);
103         }
104     }
105
106     /* (non-Javadoc)
107      * @see com.simulacramedia.contentmanager.actions.CMAction#getMenuItem()
108      */

109     public JMenuItem getMenuItem() {
110         JMenuItem menuItem = super.getMenuItem();
111         menuItem.setAccelerator( KeyStroke.getKeyStroke(this.getAcceleratorKeycode(), this.getAcceleratorMask()) );
112         
113         return menuItem;
114     }
115
116     /* (non-Javadoc)
117      * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
118      */

119     public String JavaDoc getDescription() {
120         return "Exports the currently selected resource to your local file system";
121     }
122
123     /* (non-Javadoc)
124      * @see com.simulacramedia.contentmanager.actions.CMAction#getText()
125      */

126     public String JavaDoc getText() {
127         return "Export...";
128     }
129
130     /* (non-Javadoc)
131      * @see com.simulacramedia.contentmanager.actions.CMAction#getToolTip()
132      */

133     public String JavaDoc getToolTip() {
134         return this.getDescription();
135     }
136
137     /* (non-Javadoc)
138      * @see com.simulacramedia.contentmanager.actions.CMAction#getIcon()
139      */

140     public Icon getIcon() {
141         return IconManager.getInstance().getIcon("16-blank.gif");
142     }
143
144     /* (non-Javadoc)
145      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
146      */

147     public int getAcceleratorKeycode() {
148         return KeyEvent.VK_E;
149     }
150
151     /* (non-Javadoc)
152      * @see com.simulacramedia.contentmanager.actions.CMAction#getMnemonic()
153      */

154     public String JavaDoc getMnemonic() {
155         return "E";
156     }
157
158     /* (non-Javadoc)
159      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
160      */

161     public int getAcceleratorMask() {
162         return InputEvent.CTRL_MASK;
163     }
164
165 }
166
Popular Tags