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.window.messages.builders.*; 29 import org.openharmonise.him.window.session.*; 30 import org.openharmonise.vfs.*; 31 import org.openharmonise.vfs.context.*; 32 import org.openharmonise.vfs.gui.*; 33 import org.openharmonise.vfs.status.*; 34 35 36 43 public class ActionRetrieve extends AbstractHIMAction implements HIMAction { 44 45 public static String ACTION_NAME = "RETRIEVE"; 46 47 50 private static final String WAIT_LABEL = "RETRIEVE-ACTION"; 51 52 55 public ActionRetrieve() { 56 super(); 57 this.setup(); 58 } 59 60 63 public ActionRetrieve(VirtualFile vfFile) { 64 super(vfFile); 65 this.setup(); 66 } 67 68 72 private void setup() { 73 RuleGroup andGroupTop = new RuleGroup(); 74 andGroupTop.setGroupType(RuleGroup.GROUPTYPE_AND); 75 76 RuleGroup orGroup = new RuleGroup(); 77 orGroup.setGroupType(RuleGroup.GROUPTYPE_OR); 78 79 RuleGroup andGroup = new RuleGroup(); 80 andGroup.setGroupType(RuleGroup.GROUPTYPE_AND); 81 82 EnableRule isDirRule = new IsDirectoryRule(); 83 isDirRule.setResultComparator(false); 84 andGroup.addEnableRule(isDirRule); 85 EnableRule pathRule = new PathRule("/webdav/Archive/"); 86 andGroup.addEnableRule(pathRule); 87 orGroup.addEnableRule(andGroup); 88 89 EnableRule isHistorical = new IsHistoricalRule(); 90 orGroup.addEnableRule(isHistorical); 91 92 andGroupTop.addEnableRule(orGroup); 93 94 SecurityRule secRule = new SecurityRule(VirtualFile.METHOD_CHECKOUT); 95 andGroupTop.addEnableRule(secRule); 96 97 this.addEnableRule(andGroupTop); 98 } 99 100 103 public void actionPerformed(ActionEvent arg0) { 104 VirtualFile vfFile = this.getLastContextFile(); 105 StatusData statusOverall = new VFSStatus(); 106 107 if (vfFile.isVersionable()) { 108 VersionedVirtualFile vfVerFile = (VersionedVirtualFile) vfFile; 109 StateHandler.getInstance().addWait(WAIT_LABEL); 110 String sFileName = null; 111 try { 112 sFileName = 113 vfFile.getVFS().getVirtualFileSystemView().getDisplayName( 114 vfFile); 115 String sMessage = null; 116 StatusData status = ((VersionedVirtualFile)this.getLastContextFile()).reactivate(); 117 statusOverall.addStatusData(status); 118 119 if (status.isOK()) { 120 super.fireSessionEvent("Retrieved", this.getLastContextFile().getVFS(), this.getLastContextFile().getFullPath(), SessionEventData.RESOURCE_REACTIVATED); 121 } else { 122 } 123 } catch (Exception e) { 124 e.printStackTrace(System.err); 125 statusOverall.setStatusLevel(StatusData.LEVEL_ERROR); 126 } finally { 127 StateHandler.getInstance().removeWait(WAIT_LABEL); 128 this.getLastContextDirectory().refreshChildren(); 129 VFSMessageBuilder.getInstance().fireMessage(ActionRetrieve.ACTION_NAME, statusOverall, sFileName); 130 } 131 } 132 } 133 134 137 public String getDescription() { 138 return "Retrieves the currently selected resource from the archive"; 139 } 140 141 144 public String getText() { 145 return "Retrieve"; 146 } 147 148 151 public String getToolTip() { 152 return this.getDescription(); 153 } 154 155 158 public Icon getIcon() { 159 return IconManager.getInstance().getIcon("16-command-retrieve.gif"); 160 } 161 162 165 public int getAcceleratorKeycode() { 166 return 0; 167 } 168 169 172 public String getMnemonic() { 173 return "R"; 174 } 175 176 179 public int getAcceleratorMask() { 180 return 0; 181 } 182 183 } 184 | Popular Tags |