1 19 package org.openharmonise.him.actions.move; 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.vfs.*; 30 import org.openharmonise.vfs.context.*; 31 import org.openharmonise.vfs.gui.*; 32 import org.openharmonise.vfs.status.*; 33 34 35 42 public class ActionCopy extends AbstractHIMAction implements HIMAction { 43 44 public static String ACTION_NAME = "COPY"; 45 46 private VirtualFile m_vfToFile = null; 47 48 51 private ActionCopy() { 52 super(); 53 this.setup(); 54 } 55 56 59 public ActionCopy(VirtualFile vfFromFile, VirtualFile vfToFile) { 60 super(vfFromFile); 61 this.m_vfToFile = vfToFile; 62 this.setup(); 63 } 64 65 69 private void setup() { 70 SecurityRule secRule = new SecurityRule(VirtualFile.METHOD_COPY); 71 super.addEnableRule(secRule); 72 } 73 74 77 public void actionPerformed(ActionEvent arg0) { 78 StateHandler.getInstance().addWait("COPY-ACTION"); 79 StatusData statusOverall = new VFSStatus(); 80 81 String sOriginalName = this.getPrimaryFile().getVFS().getVirtualFileSystemView().getDisplayName(this.getPrimaryFile()); 82 83 String sNewName = this.m_vfToFile.getVFS().getVirtualFileSystemView().getDisplayName(this.m_vfToFile); 84 try { 85 StatusData status = this.getPrimaryFile().copy(this.m_vfToFile.getFullPath()); 86 statusOverall.addStatusData(status); 87 if( status.isOK() ) { 88 89 } else { 90 91 } 92 } catch (Exception e) { 93 e.printStackTrace(System.err); 94 statusOverall.setStatusLevel(StatusData.LEVEL_ERROR); 95 } finally { 96 VFSMessageBuilder.getInstance().fireMessage(ActionCopy.ACTION_NAME, statusOverall, sOriginalName, sNewName); 97 StateHandler.getInstance().removeWait("COPY-ACTION"); 98 } 99 } 100 101 104 public String getText() { 105 return "Copy"; 106 } 107 108 111 public String getToolTip() { 112 return this.getDescription(); 113 } 114 115 118 public Icon getIcon() { 119 return IconManager.getInstance().getIcon("16-command-copy.gif"); 120 } 121 122 125 public String getMnemonic() { 126 return "C"; 127 } 128 129 132 public String getDescription() { 133 return "Copies resource between collections"; 134 } 135 136 139 public int getAcceleratorKeycode() { 140 return 0; 141 } 142 143 146 public int getAcceleratorMask() { 147 return 0; 148 } 149 150 } 151 | Popular Tags |