/** * {@inheritDoc} * * <p>The composite change sends <code>isValid</code> to all its children until the first one * returns a status with a severity of <code>FATAL * </code>. If one of the children throws an exception the remaining children will not receive the * <code>isValid</code> call. * * <p>Client are allowed to extend this method. */ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { RefactoringStatus result = new RefactoringStatus(); pm.beginTask("", fChanges.size()); // $NON-NLS-1$ for (Iterator iter = fChanges.iterator(); iter.hasNext() && !result.hasFatalError(); ) { Change change = (Change) iter.next(); if (change.isEnabled()) result.merge(change.isValid(new SubProgressMonitor(pm, 1))); else pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } pm.done(); return result; }
public void setChanges(@NotNull ArrayList<Change> changes) { if (myChanges != null) { HashSet<Change> newChanges = new HashSet<>(changes); LOG.assertTrue(newChanges.size() == changes.size()); for (Iterator<Change> iterator = myChanges.iterator(); iterator.hasNext(); ) { Change oldChange = iterator.next(); if (!newChanges.contains(oldChange)) { iterator.remove(); oldChange.onRemovedFromList(); } } } for (Change change : changes) { LOG.assertTrue(change.isValid()); } myChanges = new ArrayList<>(changes); myAppliedChanges = new ArrayList<>(); }