use of org.eclipse.ui.actions.MoveFilesAndFoldersOperation in project translationstudio8 by heartsome.
the class ResourceDropAdapterAssistant method validateTarget.
/**
* Ensures that the drop target meets certain criteria
*/
private IStatus validateTarget(Object target, TransferData transferType, int dropOperation) {
if (!(target instanceof IResource)) {
return WorkbenchNavigatorPlugin.createInfoStatus(WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_targetMustBeResource);
}
IResource resource = (IResource) target;
if (!resource.isAccessible()) {
return WorkbenchNavigatorPlugin.createErrorStatus(WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject);
}
IContainer destination = getActualTarget(resource);
if (destination.getType() == IResource.ROOT) {
return WorkbenchNavigatorPlugin.createErrorStatus(WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings);
}
String message = null;
// drag within Eclipse?
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
IResource[] selectedResources = getSelectedResources();
if (selectedResources.length == 0) {
message = WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_dropOperationErrorOther;
} else {
CopyFilesAndFoldersOperation operation;
if ((dropOperation == DND.DROP_COPY) || (dropOperation == DND.DROP_LINK)) {
operation = new CopyFilesAndFoldersOperation(getShell());
if (operation.validateDestination(destination, selectedResources) != null) {
operation.setVirtualFolders(true);
message = operation.validateDestination(destination, selectedResources);
}
} else {
operation = new MoveFilesAndFoldersOperation(getShell());
if (operation.validateDestination(destination, selectedResources) != null) {
operation.setVirtualFolders(true);
message = operation.validateDestination(destination, selectedResources);
}
}
}
} else // file import?
if (FileTransfer.getInstance().isSupportedType(transferType)) {
String[] sourceNames = (String[]) FileTransfer.getInstance().nativeToJava(transferType);
if (sourceNames == null) {
// source names will be null on Linux. Use empty names to do
// destination validation.
// Fixes bug 29778
sourceNames = new String[0];
}
CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell());
message = copyOperation.validateImportDestination(destination, sourceNames);
}
if (message != null) {
return WorkbenchNavigatorPlugin.createErrorStatus(message);
}
return Status.OK_STATUS;
}
use of org.eclipse.ui.actions.MoveFilesAndFoldersOperation in project translationstudio8 by heartsome.
the class ResourceDropAdapterAssistant method validatePluginTransferDrop.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validatePluginTransferDrop(org.eclipse.jface.viewers.IStructuredSelection,
* java.lang.Object)
*/
public IStatus validatePluginTransferDrop(IStructuredSelection aDragSelection, Object aDropTarget) {
if (!(aDropTarget instanceof IResource)) {
return WorkbenchNavigatorPlugin.createStatus(IStatus.INFO, 0, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_targetMustBeResource, null);
}
IResource resource = (IResource) aDropTarget;
if (!resource.isAccessible()) {
return WorkbenchNavigatorPlugin.createErrorStatus(0, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject, null);
}
IContainer destination = getActualTarget(resource);
if (destination.getType() == IResource.ROOT) {
return WorkbenchNavigatorPlugin.createErrorStatus(0, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings, null);
}
IResource[] selectedResources = getSelectedResources(aDragSelection);
String message = null;
if (selectedResources.length == 0) {
message = WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_dropOperationErrorOther;
} else {
MoveFilesAndFoldersOperation operation;
operation = new MoveFilesAndFoldersOperation(getShell());
message = operation.validateDestination(destination, selectedResources);
}
if (message != null) {
return WorkbenchNavigatorPlugin.createErrorStatus(0, message, null);
}
return Status.OK_STATUS;
}
use of org.eclipse.ui.actions.MoveFilesAndFoldersOperation in project translationstudio8 by heartsome.
the class ResourceDropAdapterAssistant method validateDrop.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validateDrop(java.lang.Object,
* int, org.eclipse.swt.dnd.TransferData)
*/
public IStatus validateDrop(Object target, int aDropOperation, TransferData transferType) {
if (!(target instanceof IResource)) {
return WorkbenchNavigatorPlugin.createStatus(IStatus.INFO, 0, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_targetMustBeResource, null);
}
IResource resource = (IResource) target;
if (!resource.isAccessible()) {
return WorkbenchNavigatorPlugin.createErrorStatus(0, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject, null);
}
IContainer destination = getActualTarget(resource);
if (destination.getType() == IResource.ROOT) {
return WorkbenchNavigatorPlugin.createErrorStatus(0, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings, null);
}
String message = null;
// drag within Eclipse?
if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
IResource[] selectedResources = getSelectedResources();
boolean bProjectDrop = false;
for (int iRes = 0; iRes < selectedResources.length; iRes++) {
IResource res = selectedResources[iRes];
if (res instanceof IProject) {
bProjectDrop = true;
}
}
if (bProjectDrop) {
// drop of projects not supported on other IResources
// "Path for project must have only one segment."
message = WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_canNotDropProjectIntoProject;
} else {
if (selectedResources.length == 0) {
message = WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_dropOperationErrorOther;
} else {
CopyFilesAndFoldersOperation operation;
if (aDropOperation == DND.DROP_COPY) {
if (Policy.DEBUG_DND) {
System.out.println(//$NON-NLS-1$
"ResourceDropAdapterAssistant.validateDrop validating COPY.");
}
operation = new CopyFilesAndFoldersOperation(getShell());
} else {
if (Policy.DEBUG_DND) {
System.out.println(//$NON-NLS-1$
"ResourceDropAdapterAssistant.validateDrop validating MOVE.");
}
operation = new MoveFilesAndFoldersOperation(getShell());
}
if (operation.validateDestination(destination, selectedResources) != null) {
operation.setVirtualFolders(true);
message = operation.validateDestination(destination, selectedResources);
}
}
}
} else // file import?
if (FileTransfer.getInstance().isSupportedType(transferType)) {
String[] sourceNames = (String[]) FileTransfer.getInstance().nativeToJava(transferType);
if (sourceNames == null) {
// source names will be null on Linux. Use empty names to do
// destination validation.
// Fixes bug 29778
sourceNames = new String[0];
}
CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell());
message = copyOperation.validateImportDestination(destination, sourceNames);
}
if (message != null) {
return WorkbenchNavigatorPlugin.createErrorStatus(0, message, null);
}
return Status.OK_STATUS;
}
use of org.eclipse.ui.actions.MoveFilesAndFoldersOperation in project translationstudio8 by heartsome.
the class ResourceDropAdapterAssistant method handlePluginTransferDrop.
/* (non-Javadoc)
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handlePluginTransferDrop(org.eclipse.jface.viewers.IStructuredSelection, java.lang.Object)
*/
public IStatus handlePluginTransferDrop(IStructuredSelection aDragSelection, Object aDropTarget) {
IContainer target = getActualTarget((IResource) aDropTarget);
IResource[] resources = getSelectedResources(aDragSelection);
MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
operation.copyResources(resources, target);
if (target != null && target.isAccessible()) {
try {
target.refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e) {
}
}
return Status.OK_STATUS;
}
Aggregations