org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory Java Examples

The following examples show how to use org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory. 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: JavaRenameProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public final RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
	ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
	IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
	RefactoringStatus result= doCheckFinalConditions(pm, context);
	if (result.hasFatalError())
		return result;
	IFile[] changed= getChangedFiles();
	for (int i= 0; i < changed.length; i++) {
		deltaFactory.change(changed[i]);
	}
	fRenameModifications= computeRenameModifications();
	fRenameModifications.buildDelta(deltaFactory);
	fRenameModifications.buildValidateEdits((ValidateEditChecker)context.getChecker(ValidateEditChecker.class));
	return result;
}
 
Example #2
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 #3
Source File: CloseResourceAction.java    From gama with GNU General Public License v3.0 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 #4
Source File: ReorgPolicyFactory.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context, IReorgQueries reorgQueries) throws CoreException {
	Assert.isNotNull(reorgQueries);
	ResourceChangeChecker checker= context.getChecker(ResourceChangeChecker.class);
	IFile[] allModifiedFiles= getAllModifiedFiles();
	RefactoringModifications modifications= getModifications();
	IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
	for (int i= 0; i < allModifiedFiles.length; i++) {
		deltaFactory.change(allModifiedFiles[i]);
	}
	if (modifications != null) {
		modifications.buildDelta(deltaFactory);
		modifications.buildValidateEdits(context.getChecker(ValidateEditChecker.class));
	}
	return new RefactoringStatus();
}
 
Example #5
Source File: JavaRenameProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public final RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
	ResourceChangeChecker checker= context.getChecker(ResourceChangeChecker.class);
	IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
	RefactoringStatus result= doCheckFinalConditions(pm, context);
	if (result.hasFatalError()) {
		return result;
	}
	IFile[] changed= getChangedFiles();
	for (int i= 0; i < changed.length; i++) {
		deltaFactory.change(changed[i]);
	}
	fRenameModifications= computeRenameModifications();
	fRenameModifications.buildDelta(deltaFactory);
	fRenameModifications.buildValidateEdits(context.getChecker(ValidateEditChecker.class));
	return result;
}
 
Example #6
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);
}
 
Example #7
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.copy(fResource, fDestination);
}
 
Example #8
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	if (fDeltaDescriptions == null)
		return;
	for (Iterator<DeltaDescription> iter= fDeltaDescriptions.iterator(); iter.hasNext();) {
		iter.next().buildDelta(builder);
	}
}
 
Example #9
Source File: Checks.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void addModifiedFilesToChecker(IFile[] filesToModify, CheckConditionsContext context) {
	ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
	IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();

	for (int i= 0; i < filesToModify.length; i++) {
		deltaFactory.change(filesToModify[i]);
	}
}
 
Example #10
Source File: RenameModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fRename.size(); i++) {
		Object element= fRename.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildMoveDelta(builder, (IResource) element, (RenameArguments) fRenameArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #11
Source File: RenameModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fRename.size(); i++) {
		Object element= fRename.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildMoveDelta(builder, (IResource) element, (RenameArguments) fRenameArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #12
Source File: CopyModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fCopies.size(); i++) {
		Object element= fCopies.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildCopyDelta(builder, (IResource) element, (CopyArguments) fCopyArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #13
Source File: JavaDeleteProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
	pm.beginTask(RefactoringCoreMessages.DeleteRefactoring_1, 1);
	try{
		fWasCanceled= false;
		RefactoringStatus result= new RefactoringStatus();

		recalculateElementsToDelete();

		checkDirtyCompilationUnits(result);
		checkDirtyResources(result);
		fDeleteModifications= new DeleteModifications();
		fDeleteModifications.delete(fResources);
		fDeleteModifications.delete(fJavaElements);
		List<IResource> packageDeletes= fDeleteModifications.postProcess();

		TextChangeManager manager= new TextChangeManager();
		fDeleteChange= DeleteChangeCreator.createDeleteChange(manager, fResources, fJavaElements, getProcessorName(), packageDeletes);

		ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
		IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
		fDeleteModifications.buildDelta(deltaFactory);
		IFile[] files= ResourceUtil.getFiles(manager.getAllCompilationUnits());
		for (int i= 0; i < files.length; i++) {
			deltaFactory.change(files[i]);
		}
		return result;
	} catch (OperationCanceledException e) {
		fWasCanceled= true;
		throw e;
	} finally{
		pm.done();
	}
}
 
Example #14
Source File: MoveModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fMoves.size(); i++) {
		Object element= fMoves.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildMoveDelta(builder, (IResource) element, (MoveArguments) fMoveArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #15
Source File: MoveModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fMoves.size(); i++) {
		Object element= fMoves.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildMoveDelta(builder, (IResource) element, (MoveArguments) fMoveArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #16
Source File: ReorgPolicyFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context, IReorgQueries reorgQueries) throws CoreException {
	Assert.isNotNull(reorgQueries);
	ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
	IFile[] allModifiedFiles= getAllModifiedFiles();
	RefactoringModifications modifications= getModifications();
	IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
	for (int i= 0; i < allModifiedFiles.length; i++) {
		deltaFactory.change(allModifiedFiles[i]);
	}
	if (modifications != null) {
		modifications.buildDelta(deltaFactory);
		modifications.buildValidateEdits((ValidateEditChecker) context.getChecker(ValidateEditChecker.class));
	}
	return new RefactoringStatus();
}
 
Example #17
Source File: CopyModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	for (int i= 0; i < fCopies.size(); i++) {
		Object element= fCopies.get(i);
		if (element instanceof IResource) {
			ResourceModifications.buildCopyDelta(builder, (IResource) element, (CopyArguments) fCopyArguments.get(i));
		}
	}
	getResourceModifications().buildDelta(builder);
}
 
Example #18
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	if (fDeltaDescriptions == null)
		return;
	for (Iterator<DeltaDescription> iter= fDeltaDescriptions.iterator(); iter.hasNext();) {
		iter.next().buildDelta(builder);
	}
}
 
Example #19
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.copy(fResource, fDestination);
}
 
Example #20
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 #21
Source File: DeleteModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory deltaFactory) {
	getResourceModifications().buildDelta(deltaFactory);
}
 
Example #22
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void buildCopyDelta(IResourceChangeDescriptionFactory builder, IResource resource, CopyArguments args) {
	IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
	new CopyDescription(resource, destination).buildDelta(builder);
}
 
Example #23
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, MoveArguments args) {
	IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
	new MoveDescription(resource, destination).buildDelta(builder);
}
 
Example #24
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, RenameArguments args) {
	IPath newPath= resource.getFullPath().removeLastSegments(1).append(args.getNewName());
	new MoveDescription(resource, newPath).buildDelta(builder);
}
 
Example #25
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	builder.create(fResource);
}
 
Example #26
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	builder.create(fResource);
}
 
Example #27
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	builder.change((IFile)fResource);
}
 
Example #28
Source File: ResourceModifications.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	builder.delete(fResource);
}
 
Example #29
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void buildDelta(IResourceChangeDescriptionFactory builder) {
	builder.delete(fResource);
}
 
Example #30
Source File: ResourceModifications.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static void buildCopyDelta(IResourceChangeDescriptionFactory builder, IResource resource, CopyArguments args) {
	IPath destination= ((IResource)args.getDestination()).getFullPath().append(resource.getName());
	new CopyDescription(resource, destination).buildDelta(builder);
}