001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.actions.publish;
020:
021: import java.awt.event.*;
022:
023: import javax.swing.*;
024:
025: import org.openharmonise.him.actions.*;
026: import org.openharmonise.him.actions.rules.*;
027: import org.openharmonise.him.context.StateHandler;
028: import org.openharmonise.him.editors.*;
029: import org.openharmonise.him.harmonise.*;
030: import org.openharmonise.him.window.messages.builders.*;
031: import org.openharmonise.vfs.*;
032: import org.openharmonise.vfs.context.*;
033: import org.openharmonise.vfs.gui.*;
034: import org.openharmonise.vfs.status.*;
035:
036: /**
037: * Action to export a virtual file.
038: *
039: * @author Matthew Large
040: * @version $Revision: 1.1 $
041: *
042: */
043: public class ActionExport extends AbstractHIMAction implements
044: HIMAction {
045:
046: public static String ACTION_NAME = "EXPORT";
047:
048: /**
049: * Wait identifier for state handler.
050: */
051: private static final String WAIT_LABEL = "EXPORT-ACTION";
052:
053: /**
054: *
055: */
056: public ActionExport() {
057: super ();
058: this .setup();
059: }
060:
061: /**
062: * @param vfFile
063: */
064: public ActionExport(VirtualFile vfFile) {
065: super (vfFile);
066: this .setup();
067: }
068:
069: /**
070: * Configures this action.
071: *
072: */
073: private void setup() {
074: PathRule pathRule = new PathRule(HarmonisePaths.PATH_DOCUMENTS);
075: this .addEnableRule(pathRule);
076: pathRule = new PathRule(HarmonisePaths.PATH_IMAGES);
077: this .addEnableRule(pathRule);
078: pathRule = new PathRule(HarmonisePaths.PATH_PDF);
079: this .addEnableRule(pathRule);
080: pathRule = new PathRule(HarmonisePaths.PATH_FLASH);
081: this .addEnableRule(pathRule);
082: pathRule = new PathRule(HarmonisePaths.PATH_REPORTS_OUTPUT);
083: this .addEnableRule(pathRule);
084: }
085:
086: /* (non-Javadoc)
087: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
088: */
089: public void actionPerformed(ActionEvent arg0) {
090: StatusData statusOverall = new VFSStatus();
091: VirtualFile vfFile = this .getLastContextFile();
092: StateHandler.getInstance().addWait(WAIT_LABEL);
093: String sFileName = vfFile.getVFS().getVirtualFileSystemView()
094: .getDisplayName(vfFile);
095: try {
096: StatusData status = EditorController.getInstance().export(
097: vfFile.getFullPath(),
098: this .getLastContextFile().getVFS());
099: statusOverall.addStatusData(status);
100: } catch (Exception e) {
101: e.printStackTrace(System.err);
102: statusOverall.setStatusLevel(StatusData.LEVEL_ERROR);
103: } finally {
104: StateHandler.getInstance().removeWait(WAIT_LABEL);
105: VFSMessageBuilder.getInstance().fireMessage(
106: ActionExport.ACTION_NAME, statusOverall, sFileName);
107: }
108: }
109:
110: /* (non-Javadoc)
111: * @see com.simulacramedia.contentmanager.actions.CMAction#getMenuItem()
112: */
113: public JMenuItem getMenuItem() {
114: JMenuItem menuItem = super .getMenuItem();
115: menuItem.setAccelerator(KeyStroke.getKeyStroke(this
116: .getAcceleratorKeycode(), this .getAcceleratorMask()));
117:
118: return menuItem;
119: }
120:
121: /* (non-Javadoc)
122: * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
123: */
124: public String getDescription() {
125: return "Exports the currently selected resource to your local file system";
126: }
127:
128: /* (non-Javadoc)
129: * @see com.simulacramedia.contentmanager.actions.CMAction#getText()
130: */
131: public String getText() {
132: return "Export...";
133: }
134:
135: /* (non-Javadoc)
136: * @see com.simulacramedia.contentmanager.actions.CMAction#getToolTip()
137: */
138: public String getToolTip() {
139: return this .getDescription();
140: }
141:
142: /* (non-Javadoc)
143: * @see com.simulacramedia.contentmanager.actions.CMAction#getIcon()
144: */
145: public Icon getIcon() {
146: return IconManager.getInstance().getIcon("16-blank.gif");
147: }
148:
149: /* (non-Javadoc)
150: * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
151: */
152: public int getAcceleratorKeycode() {
153: return KeyEvent.VK_E;
154: }
155:
156: /* (non-Javadoc)
157: * @see com.simulacramedia.contentmanager.actions.CMAction#getMnemonic()
158: */
159: public String getMnemonic() {
160: return "E";
161: }
162:
163: /* (non-Javadoc)
164: * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
165: */
166: public int getAcceleratorMask() {
167: return InputEvent.CTRL_MASK;
168: }
169:
170: }
|