Java Code Examples for org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory#move()

The following examples show how to use org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory#move() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopyFilesAndFoldersOperation.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validates the copy or move operation.
 *
 * @param resources
 *            the resources being copied or moved
 * @param destinationPath
 *            the destination of the copy or move
 * @return whether the operation should proceed
 * @since 3.2
 */
private boolean validateOperation(IResource[] resources, IPath destinationPath) {
    IResourceChangeDescriptionFactory factory = ResourceChangeValidator.getValidator().createDeltaFactory();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        if (isMove()) {
            factory.move(resource, destinationPath.append(resource.getName()));
        } else {
            factory.copy(resource, destinationPath.append(resource.getName()));
        }
    }
    String title;
    String message;
    if (isMove()) {
        title = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_confirmMove;
        message = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_warningMove;
    } else {
        title = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_confirmCopy;
        message = IDEWorkbenchMessages.CopyFilesAndFoldersOperation_warningCopy;
    }
    return IDE
            .promptToConfirm(messageShell, title, message, factory.getDelta(), modelProviderIds,
                    true /* syncExec */);
}
 
Example 2
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	IResource existing= ResourcesPlugin.getWorkspace().getRoot().findMember(fDestination);
	if (existing != null && !existing.equals(fResource)) {
		builder.delete(existing);
	}
	builder.move(fResource, fDestination);
}
 
Example 3
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	IResource existing= ResourcesPlugin.getWorkspace().getRoot().findMember(fDestination);
	if (existing != null && !existing.equals(fResource)) {
		builder.delete(existing);
	}
	builder.move(fResource, fDestination);
}