resetDiffs();
fHasErrors = false; // start with no errors
CompareConfiguration cc = getCompareConfiguration();
IMergeViewerContentProvider cp = getMergeContentProvider();
if (cp instanceof MergeViewerContentProvider) {
MergeViewerContentProvider mcp = (MergeViewerContentProvider) cp;
mcp.setAncestorError(null);
mcp.setLeftError(null);
mcp.setRightError(null);
}
// Record current contributors so we disconnect after creating the new
// ones.
// This is done in case the old and new use the same document.
ContributorInfo oldLeftContributor = fLeftContributor;
ContributorInfo oldRightContributor = fRightContributor;
ContributorInfo oldAncestorContributor = fAncestorContributor;
// Create the new contributor
fLeftContributor = createLegInfoFor(left, LEFT_CONTRIBUTOR);
fRightContributor = createLegInfoFor(right, RIGHT_CONTRIBUTOR);
fAncestorContributor = createLegInfoFor(ancestor, ANCESTOR_CONTRIBUTOR);
fLeftContributor.transferContributorStateFrom(oldLeftContributor);
fRightContributor.transferContributorStateFrom(oldRightContributor);
fAncestorContributor
.transferContributorStateFrom(oldAncestorContributor);
// Now disconnect the old ones
disconnect(oldLeftContributor);
disconnect(oldRightContributor);
disconnect(oldAncestorContributor);
// Get encodings from streams. If an encoding is null, abide by the
// other one
// Defaults to workbench encoding only if both encodings are null
fLeftContributor.setEncodingIfAbsent(fRightContributor);
fRightContributor.setEncodingIfAbsent(fLeftContributor);
fAncestorContributor.setEncodingIfAbsent(fLeftContributor);
// set new documents
fLeftContributor.setDocument(fLeft,
cc.isLeftEditable() && cp.isLeftEditable(input));
fLeftLineCount = fLeft.getLineCount();
fRightContributor.setDocument(fRight,
cc.isRightEditable() && cp.isRightEditable(input));
fRightLineCount = fRight.getLineCount();
fAncestorContributor.setDocument(fAncestor, false);
// if the input is part of a patch hunk, toggle synchronized scrolling