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 ActionMove extends AbstractHIMAction implements HIMAction { 43 44 public static String ACTION_NAME = "MOVE"; 45 46 49 private VirtualFile m_vfToFile = null; 50 51 54 private ActionMove() { 55 super(); 56 this.setup(); 57 } 58 59 62 public ActionMove(VirtualFile vfFromFile, VirtualFile vfToFile) { 63 super(vfFromFile); 64 this.m_vfToFile = vfToFile; 65 this.setup(); 66 } 67 68 72 private void setup() { 73 SecurityRule secRule = new SecurityRule(VirtualFile.METHOD_MOVE); 74 super.addEnableRule(secRule); 75 } 76 77 80 public void actionPerformed(ActionEvent arg0) { 81 StateHandler.getInstance().addWait("MOVE-ACTION"); 82 StatusData statusOverall = new VFSStatus(); 83 84 String sOriginalName = this.getPrimaryFile().getVFS().getVirtualFileSystemView().getDisplayName(this.getPrimaryFile()); 85 86 String sNewName = this.m_vfToFile.getVFS().getVirtualFileSystemView().getDisplayName(this.m_vfToFile); 87 try { 88 StatusData status = this.getPrimaryFile().move(this.m_vfToFile.getFullPath()); 89 statusOverall.addStatusData(status); 90 if( status.isOK() ) { 91 92 } else { 93 94 } 95 } catch (Exception e) { 96 e.printStackTrace(System.err); 97 statusOverall.setStatusLevel(StatusData.LEVEL_ERROR); 98 } finally { 99 VFSMessageBuilder.getInstance().fireMessage(ActionMove.ACTION_NAME, statusOverall, sOriginalName, sNewName); 100 StateHandler.getInstance().removeWait("MOVE-ACTION"); 101 } 102 } 103 104 107 public String getText() { 108 return "Move"; 109 } 110 111 114 public String getToolTip() { 115 return this.getDescription(); 116 } 117 118 121 public Icon getIcon() { 122 return IconManager.getInstance().getIcon("16-command-move.gif"); 123 } 124 125 128 public String getMnemonic() { 129 return "M"; 130 } 131 132 135 public String getDescription() { 136 return "Moves resource between collections"; 137 } 138 139 142 public int getAcceleratorKeycode() { 143 return 0; 144 } 145 146 149 public int getAcceleratorMask() { 150 return 0; 151 } 152 153 } 154 | Popular Tags |