setImageDescriptor(icons.getDescriptor(CFPluginImages.ICON_PASTE));
}
public void run() {
// Get the destination folder from tree
VFSView fVFSView = vfsView;
TableItem[] tableItems = fVFSView.getTable().getSelection();
TreeItem[] treeItems = fVFSView.getTree().getSelection();
// if no table items then use tree items
boolean useTree = (tableItems.length == 0) ? true : false;
String destUri = null;
String destConnectionId = null;
int size = (useTree) ? treeItems.length : tableItems.length;
if (useTree) {
destUri = (String) treeItems[0].getData(VFSView.TREEITEMDATA_URI);
destConnectionId = (String) treeItems[0].getData(VFSView.TREEITEMDATA_CONNECTIONID);
} else {
final FileObject destFile = ((FileObject) tableItems[0].getData(VFSView.TABLEITEMDATA_FILE));
try {
destUri = destFile.getURL().toString();
} catch (FileSystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
destConnectionId = (String) tableItems[0].getData(VFSView.TABLEITEMDATA_CONNECTIONID);
}
// Source URIs from clipboard
Clipboard clip = getClipboard();
if (clip != null && destUri != null) {
String tmp = (String) clip.getContents(TextTransfer.getInstance());
String[] paths = tmp.split(" ");
FileSystemManager fsManager = fVFSView.getFileSystemManager();
try {
// destination object
FileObject targetFile = fVFSView.resolveURI(destUri, destConnectionId);
VFSUtil.copyFiles(fsManager, paths, fVFSView.fConnections.get(fVFSView.fSourceConnectionId),
targetFile, fVFSView.fConnections.get(destConnectionId));
// refresh
fVFSView.notifyRefreshFiles(new FileObject[] { targetFile });
} catch (FileSystemException e) {
VFSView.debug(e);
}
}