Search in sources :

Example 1 with IResourceChangeDescriptionFactory

use of org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory in project che by eclipse.

the class JavaRenameProcessor method checkFinalConditions.

@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;
}
Also used : IFile(org.eclipse.core.resources.IFile) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory) ResourceChangeChecker(org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)

Example 2 with IResourceChangeDescriptionFactory

use of org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory in project che by eclipse.

the class DeleteResourcesProcessor method checkFinalConditions.

/* (non-Javadoc)
	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
	 */
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException {
    //$NON-NLS-1$
    pm.beginTask("", 1);
    try {
        RefactoringStatus result = new RefactoringStatus();
        for (int i = 0; i < fResources.length; i++) {
            IResource resource = fResources[i];
            if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
                String pathLabel = BasicElementLabels.getPathLabel(resource.getFullPath(), false);
                String locationLabel = null;
                IPath location = resource.getLocation();
                if (location != null) {
                    locationLabel = BasicElementLabels.getPathLabel(location, true);
                } else {
                    URI uri = resource.getLocationURI();
                    if (uri != null) {
                        locationLabel = BasicElementLabels.getURLPart(uri.toString());
                    }
                }
                String warning;
                if (resource instanceof IFile) {
                    if (locationLabel != null) {
                        warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_file_loc, new Object[] { pathLabel, locationLabel });
                    } else {
                        warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_file, pathLabel);
                    }
                } else {
                    if (locationLabel != null) {
                        warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_container_loc, new Object[] { pathLabel, locationLabel });
                    } else {
                        warning = Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_warning_out_of_sync_container, pathLabel);
                    }
                }
                result.addWarning(warning);
            }
        }
        checkDirtyResources(result);
        ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
        IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
        for (int i = 0; i < fResources.length; i++) {
            if (fResources[i].isPhantom()) {
                result.addFatalError(Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_delete_error_phantom, BasicElementLabels.getPathLabel(fResources[i].getFullPath(), false)));
            } else if (fDeleteContents && Resources.isReadOnly(fResources[i])) {
                result.addFatalError(Messages.format(RefactoringCoreMessages.DeleteResourcesProcessor_delete_error_read_only, BasicElementLabels.getPathLabel(fResources[i].getFullPath(), false)));
            } else {
                deltaFactory.delete(fResources[i]);
            }
        }
        return result;
    } finally {
        pm.done();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) URI(java.net.URI) IResource(org.eclipse.core.resources.IResource) IResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory) ResourceChangeChecker(org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)

Example 3 with IResourceChangeDescriptionFactory

use of org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory in project che by eclipse.

the class MoveResourcesProcessor method checkFinalConditions.

/* (non-Javadoc)
	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
	 */
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
    //$NON-NLS-1$
    pm.beginTask("", 1);
    try {
        RefactoringStatus status = validateDestination(fDestination);
        if (status.hasFatalError()) {
            return status;
        }
        fMoveArguments = new MoveArguments(fDestination, isUpdateReferences());
        ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
        IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
        for (int i = 0; i < fResourcesToMove.length; i++) {
            IResource resource = fResourcesToMove[i];
            IResource newResource = fDestination.findMember(resource.getName());
            if (newResource != null) {
                status.addWarning(Messages.format(RefactoringCoreMessages.MoveResourcesProcessor_warning_destination_already_exists, BasicElementLabels.getPathLabel(newResource.getFullPath(), false)));
                deltaFactory.delete(newResource);
            }
            ResourceModifications.buildMoveDelta(deltaFactory, fResourcesToMove[i], fMoveArguments);
        }
        return status;
    } finally {
        pm.done();
    }
}
Also used : MoveArguments(org.eclipse.ltk.core.refactoring.participants.MoveArguments) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory) IResource(org.eclipse.core.resources.IResource) ResourceChangeChecker(org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)

Example 4 with IResourceChangeDescriptionFactory

use of org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory in project che by eclipse.

the class Checks method addModifiedFilesToChecker.

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]);
    }
}
Also used : IResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory) ResourceChangeChecker(org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)

Example 5 with IResourceChangeDescriptionFactory

use of org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory in project che by eclipse.

the class RenameResourceProcessor method checkFinalConditions.

/* (non-Javadoc)
	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
	 */
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
    //$NON-NLS-1$
    pm.beginTask("", 1);
    try {
        fRenameArguments = new RenameArguments(getNewResourceName(), isUpdateReferences());
        ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
        IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
        ResourceModifications.buildMoveDelta(deltaFactory, fResource, fRenameArguments);
        return new RefactoringStatus();
    } finally {
        pm.done();
    }
}
Also used : RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IResourceChangeDescriptionFactory(org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory) ResourceChangeChecker(org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)

Aggregations

IResourceChangeDescriptionFactory (org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory)5 ResourceChangeChecker (org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker)5 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)4 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 URI (java.net.URI)1 IPath (org.eclipse.core.runtime.IPath)1 MoveArguments (org.eclipse.ltk.core.refactoring.participants.MoveArguments)1 RenameArguments (org.eclipse.ltk.core.refactoring.participants.RenameArguments)1