@Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { SubMonitor sm = SubMonitor.convert(pm, "Creating a change description.", 20); try { modelChange = new RootChange(context); modelChange.perform(pm); sm.done(); } catch (CoreException exception) { RefactoringPlugin.log(IStatus.ERROR, exception.getMessage()); modelChange = null; sm.done(); throw exception; } return modelChange; }
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { RefactoringStatus refactoringStatus = RefactoringStatus.create(Status.OK_STATUS); if (modelChange == null) { createChange(pm); } RefactoringTickProvider tickProvider = getRefactoringTickProvider(); StringBuffer taskBuffer = new StringBuffer("Checking final conditions for re-factoring "); taskBuffer.append(context.getLabel()); SubMonitor sm = SubMonitor.convert(pm, taskBuffer.toString(), tickProvider.getCheckFinalConditionsTicks()); Object modified = modelChange.getModifiedElement(); if (modified instanceof EObject) { EObject modifiedEObject = (EObject) modified; EObject container = EcoreUtil.getRootContainer(modifiedEObject); refactoringStatus = pm.isCanceled() ? RefactoringStatus.create(Status.CANCEL_STATUS) : validate(pm, container); } sm.done(); return refactoringStatus; }