1 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 44 public class ActionExport extends AbstractHIMAction implements HIMAction { 45 46 public static String ACTION_NAME = "EXPORT"; 47 48 51 private static final String WAIT_LABEL = "EXPORT-ACTION"; 52 53 56 public ActionExport() { 57 super(); 58 this.setup(); 59 } 60 61 64 public ActionExport(VirtualFile vfFile) { 65 super(vfFile); 66 this.setup(); 67 } 68 69 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 89 public void actionPerformed(ActionEvent arg0) { 90 StatusData statusOverall = new VFSStatus(); 91 VirtualFile vfFile =this.getLastContextFile(); 92 StateHandler.getInstance().addWait(WAIT_LABEL); 93 String 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 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 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 119 public String getDescription() { 120 return "Exports the currently selected resource to your local file system"; 121 } 122 123 126 public String getText() { 127 return "Export..."; 128 } 129 130 133 public String getToolTip() { 134 return this.getDescription(); 135 } 136 137 140 public Icon getIcon() { 141 return IconManager.getInstance().getIcon("16-blank.gif"); 142 } 143 144 147 public int getAcceleratorKeycode() { 148 return KeyEvent.VK_E; 149 } 150 151 154 public String getMnemonic() { 155 return "E"; 156 } 157 158 161 public int getAcceleratorMask() { 162 return InputEvent.CTRL_MASK; 163 } 164 165 } 166 | Popular Tags |