1 19 package org.openharmonise.him.actions.file; 20 21 import java.awt.event.ActionEvent ; 22 23 import javax.swing.Icon ; 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 ActionUpload extends AbstractHIMAction implements HIMAction { 45 46 public static String ACTION_NAME = "UPLOAD"; 47 48 51 public ActionUpload() { 52 super(); 53 this.setup(); 54 } 55 56 59 public ActionUpload(VirtualFile vfFile) { 60 super(vfFile); 61 this.setup(); 62 } 63 64 68 private void setup() { 69 RuleGroup andGroup = new RuleGroup(); 70 andGroup.setGroupType(RuleGroup.GROUPTYPE_AND); 71 72 EnableRule rule = new IsDirectoryRule(); 73 rule.setResultComparator(false); 74 andGroup.addEnableRule( rule ); 75 PathRule pathRule = new PathRule("/webdav/Content/Assets"); 76 andGroup.addEnableRule(pathRule); 77 pathRule = new PathRule( HarmonisePaths.PATH_EMAIL ); 78 pathRule.setResultComparator(false); 79 andGroup.addEnableRule(pathRule); 80 pathRule = new PathRule( HarmonisePaths.PATH_LINKS ); 81 pathRule.setResultComparator(false); 82 andGroup.addEnableRule(pathRule); 83 84 this.addEnableRule(andGroup); 85 } 86 87 90 public void actionPerformed(ActionEvent arg0) { 91 StatusData statusOverall = new VFSStatus(); 92 VirtualFile vfFile = this.getLastContextFile(); 93 String sFileName = vfFile.getVFS().getVirtualFileSystemView().getDisplayName(vfFile); 94 StateHandler.getInstance().addWait("UPLOAD-ACTION", 95 "Opening uploader..."); 96 try { 97 StatusData status = EditorController.getInstance().upload(vfFile.getFullPath(), 98 vfFile.getVFS()); 99 statusOverall.addStatusData(status); 100 } catch (Exception e) { 101 e.printStackTrace(System.err); 102 statusOverall.setStatusLevel(StatusData.LEVEL_ERROR); 103 } finally { 104 StateHandler.getInstance().removeWait("UPLOAD-ACTION"); 105 VFSMessageBuilder.getInstance().fireMessage(ActionUpload.ACTION_NAME, statusOverall, sFileName); 106 } 107 } 108 109 112 public String getDescription() { 113 return "Uploads content to the server"; 114 } 115 116 119 public String getText() { 120 return "Reupload..."; 121 } 122 123 126 public String getToolTip() { 127 return this.getDescription(); 128 } 129 130 133 public Icon getIcon() { 134 return IconManager.getInstance().getIcon("16-blank.gif"); 135 } 136 137 140 public int getAcceleratorKeycode() { 141 return 0; 142 } 143 144 147 public String getMnemonic() { 148 return "l"; 149 } 150 151 154 public int getAcceleratorMask() { 155 return 0; 156 } 157 158 } 159 | Popular Tags |