org.eclipse.compare.structuremergeviewer.Differencer Java Examples

The following examples show how to use org.eclipse.compare.structuremergeviewer.Differencer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4IDEXpectCompareEditorInput.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Object prepareInput(IProgressMonitor pm) {
	try {
		ResourceNode ancestor = new ResourceNode(file);
		String ancestorContent = getContent(ancestor);
		String leftContent, rightContent;

		leftContent = this.comparisonFailure.getExpected();
		rightContent = this.comparisonFailure.getActual();
		if (!leftContent.equals(ancestorContent))
			getCompareConfiguration().setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, Boolean.TRUE);
		CompareItem left = new EditableCompareItem("Left", leftContent, file);
		CompareItem right = new CompareItem("Right", rightContent);
		return new DiffNode(null, Differencer.CHANGE | Differencer.DIRECTION_MASK, ancestor, left, right);
	} catch (Throwable t) {
		LOG.error(t.getMessage(), t);
		Exceptions.throwUncheckedException(t);
		return null;
	}
}
 
Example #2
Source File: PropertyCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	initLabels();
	if (monitor != null) {
		monitor.subTask(Policy.bind("PropertyCompareInput.0") + left.getLabel()); //$NON-NLS-1$
	}
	left.getProperties(recursive);
	if (monitor != null && monitor.isCanceled()) {
		return null;
	}
	if (monitor != null) {
		monitor.subTask(Policy.bind("PropertyCompareInput.0") + right.getLabel()); //$NON-NLS-1$
	}
	right.getProperties(recursive);
	if (monitor != null && monitor.isCanceled()) {
		return null;
	}
	return new Differencer().findDifferences(false, monitor,null,null,left,right);
}
 
Example #3
Source File: SVNCompareRevisionsInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
    * Runs the compare operation and returns the compare result.
    */
protected Object prepareInput(IProgressMonitor monitor){
	initLabels();
	DiffNode diffRoot = new DiffNode(Differencer.NO_CHANGE);
	String localCharset = Utilities.getCharset(resource);
	for (int i = 0; i < logEntries.length; i++) {		
		ITypedElement left = new TypedBufferedContent(resource);
		ResourceRevisionNode right = new ResourceRevisionNode(logEntries[i]);
		try {
			right.setCharset(localCharset);
		} catch (CoreException e) {
		}
		diffRoot.add(new VersionCompareDiffNode(left, right));
	}
	return diffRoot;		
}
 
Example #4
Source File: BonitaCompareEditorInput.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void buildTree() {
    for (final ScriptContainer<?> script : scripts) {
        final LeftCompareScript left = new LeftCompareScript(script, adapterFactoryLabelProvider);
        final RightCompareScript right = new RightCompareScript(script, adapterFactoryLabelProvider);
        right.addContentChangeListener(new IContentChangeListener() {

            @Override
            public void contentChanged(final IContentChangeNotifier compareScript) {
                if (compareScript instanceof RightCompareScript) {
                    setDirty(true);
                    if (getViewer() == null || getViewer().getControl().isDisposed()) {
                        return;
                    }
                    getViewer().refresh(true);
                }
            }
        });
        final DiffNode leaf = new DiffNode(null, Differencer.CHANGE, null, left, right);
        final EObject eContainer = script.getModelElement().eContainer();
        Preconditions.checkState(eContainer != null);
        final DiffNode poolNode = buildPathNodes(eContainer, leaf);
        if (((EObjectNode) poolNode.getAncestor()).getElement() instanceof Pool && root.getChildren().length == 0) {
            root.add(poolNode);
        }
    }
}
 
Example #5
Source File: BonitaCompareEditorInput.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private DiffNode buildPathNodes(final EObject container, final DiffNode node) {
    final DiffNode parentNode = new DiffNode(Differencer.NO_CHANGE);
    node.setParent(parentNode);
    parentNode.add(node);
    final EObjectNode ancestor = new EObjectNode(container, adapterFactoryLabelProvider);
    parentNode.setAncestor(ancestor);
    if (insertParentNode(parentNode)) {
        return parentNode;
    }
    if (container instanceof Pool) {
        return parentNode;
    }
    if (container instanceof ConnectorParameter) {
        return buildPathNodes(container.eContainer().eContainer(), parentNode);
    }
    return buildPathNodes(container.eContainer(), parentNode);
}
 
Example #6
Source File: AbapGitCompareInput.java    From ADT_Frontend with MIT License 5 votes vote down vote up
@Override
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	CompareConfiguration configuration = getCompareConfiguration();
	configuration.setLeftLabel(this.left.getName());
	configuration.setRightLabel(this.right.getName());
	return new DiffNode(null, Differencer.CHANGE, null, this.left, this.right);
}
 
Example #7
Source File: JavaStructureDiffViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void postDiffHook(Differencer differencer, IDiffContainer root, IProgressMonitor monitor) {
	if (fStructureCreator.canRewriteTree()) {
		boolean smart= JavaCompareUtilities.getBoolean(getCompareConfiguration(), SMART, false);
		if (smart && root != null)
			fStructureCreator.rewriteTree(differencer, root);
	}
}
 
Example #8
Source File: StringCompareEditorInput.java    From JDeodorant with MIT License 4 votes vote down vote up
@Override
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	Differencer d = new Differencer();
	Object diff = d.findDifferences(false, new NullProgressMonitor(), null, null, new Input(input1), new Input(input2));
	return diff; 
}