Java Code Examples for org.eclipse.core.resources.mapping.ResourceChangeValidator

The following are top voted examples for showing how to use org.eclipse.core.resources.mapping.ResourceChangeValidator. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gama   File: CloseResourceAction.java   Source Code and License 6 votes vote down vote up
/**
 * Validates the operation against the model providers.
 *
 * @return whether the operation should proceed
 */
private boolean validateClose() {
	final IResourceChangeDescriptionFactory factory = ResourceChangeValidator.getValidator().createDeltaFactory();
	final List<? extends IResource> resources = getActionResources();
	for (final IResource resource : resources) {
		if (resource instanceof IProject) {
			final IProject project = (IProject) resource;
			factory.close(project);
		}
	}
	String message;
	if (resources.size() == 1) {
		message = NLS.bind(IDEWorkbenchMessages.CloseResourceAction_warningForOne, resources.get(0).getName());
	} else {
		message = IDEWorkbenchMessages.CloseResourceAction_warningForMultiple;
	}
	return IDE.promptToConfirm(WorkbenchHelper.getShell(), IDEWorkbenchMessages.CloseResourceAction_confirm,
			message, factory.getDelta(), getModelProviderIds(), false /* no need to syncExec */);
}
 
Example 2
Project: Pydev   File: CopyFilesAndFoldersOperation.java   Source Code and License 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 3
Project: che   File: ResourceChangeChecker.java   Source Code and License 4 votes vote down vote up
public ResourceChangeChecker() {
  fDeltaFactory = ResourceChangeValidator.getValidator().createDeltaFactory();
}
 
Example 4
Project: che   File: ResourceChangeChecker.java   Source Code and License 4 votes vote down vote up
public RefactoringStatus check(IProgressMonitor monitor) throws CoreException {
  IStatus status =
      ResourceChangeValidator.getValidator().validateChange(fDeltaFactory.getDelta(), monitor);
  return createFrom(status);
}
 
Example 5
Project: che   File: ResourceChangeChecker.java   Source Code and License 4 votes vote down vote up
public ResourceChangeChecker() {
  fDeltaFactory = ResourceChangeValidator.getValidator().createDeltaFactory();
}
 
Example 6
Project: che   File: ResourceChangeChecker.java   Source Code and License 4 votes vote down vote up
public RefactoringStatus check(IProgressMonitor monitor) throws CoreException {
  IStatus status =
      ResourceChangeValidator.getValidator().validateChange(fDeltaFactory.getDelta(), monitor);
  return createFrom(status);
}