@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; }
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(); }
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { pm.beginTask("", 1); // $NON-NLS-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(); } }
/** * 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 */); }
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { pm.beginTask("", 1); //$NON-NLS-1$ try { fRenameArguments = new RenameKeyArguments(getNewResourceName(), fRenameChildKeys, false); ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory(); // TODO figure out what we want to do here.... // ResourceModifications.buildMoveDelta(deltaFactory, fKeyNode, fRenameArguments); return new RefactoringStatus(); } finally { pm.done(); } }
@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; }
/** * 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 */); }
@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); }
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]); } }
@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); }
@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); }
@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); }
@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); }
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { pm.beginTask("", 1); // $NON-NLS-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(); } }
@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); }
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]); } }
@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); }
@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); }
public void buildDelta(IResourceChangeDescriptionFactory builder) { if (fDeltaDescriptions == null) return; for (Iterator<DeltaDescription> iter= fDeltaDescriptions.iterator(); iter.hasNext();) { iter.next().buildDelta(builder); } }
@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(); } }
@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); }
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(); }
@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); }
@Override public void buildDelta(IResourceChangeDescriptionFactory builder) { builder.delete(fResource); }
@Override public void buildDelta(IResourceChangeDescriptionFactory builder) { builder.change((IFile) fResource); }
@Override public void buildDelta(IResourceChangeDescriptionFactory builder) { builder.create(fResource); }
public void buildDelta(IResourceChangeDescriptionFactory builder) { if (fDeltaDescriptions == null) return; for (Iterator<DeltaDescription> iter = fDeltaDescriptions.iterator(); iter.hasNext(); ) { iter.next().buildDelta(builder); } }
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); }
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); }
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); }