本文整理汇总了Java中org.eclipse.compare.structuremergeviewer.DiffNode类的典型用法代码示例。如果您正苦于以下问题:Java DiffNode类的具体用法?Java DiffNode怎么用?Java DiffNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DiffNode类属于org.eclipse.compare.structuremergeviewer包,在下文中一共展示了DiffNode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
@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;
}
}
示例2: createPreviewer
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
private Control createPreviewer(Composite parent) {
final CompareConfiguration compareConfiguration = new CompareConfiguration();
compareConfiguration.setLeftLabel("Original " + docTypeName);
compareConfiguration.setLeftEditable(false);
compareConfiguration.setRightLabel("Updated " + docTypeName);
compareConfiguration.setRightEditable(false);
compareConfiguration.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.FALSE);
compareConfiguration.setProperty(PREFIX_SUFFIX_PROPERTY, fPrefixSuffix);
fViewer = new TextMergeViewer(parent, SWT.NONE, compareConfiguration);
// add initial input in order to avoid problems when disposing the viewer later:
fViewer.setInput(new DiffNode(new TargetElementFromString(""), new TargetElementFromString("")));
Control control = fViewer.getControl();
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
compareConfiguration.dispose();
}
});
return control;
}
示例3: commit
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
private static void commit(IProgressMonitor pm, DiffNode node) throws CoreException {
ITypedElement left= node.getLeft();
if (left instanceof BufferedResourceNode)
((BufferedResourceNode) left).commit(pm);
ITypedElement right= node.getRight();
if (right instanceof BufferedResourceNode)
((BufferedResourceNode) right).commit(pm);
IDiffElement[] children= node.getChildren();
if (children != null) {
for (int i= 0; i < children.length; i++) {
IDiffElement element= children[i];
if (element instanceof DiffNode)
commit(pm, (DiffNode) element);
}
}
}
示例4: prepareInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
/**
* 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;
}
示例5: createPreviewer
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
private Control createPreviewer(Composite parent) {
final CompareConfiguration compareConfiguration = new CompareConfiguration();
compareConfiguration.setLeftLabel("Original package.json");
compareConfiguration.setLeftEditable(false);
compareConfiguration.setRightLabel("Merged package.json");
compareConfiguration.setRightEditable(false);
compareConfiguration.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.FALSE);
fViewer = new TextMergeViewer(parent, SWT.NONE, compareConfiguration);
// add initial input in order to avoid problems when disposing the viewer later:
fViewer.setInput(new DiffNode(new DiffElementFromString(""), new DiffElementFromString("")));
Control control = fViewer.getControl();
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
compareConfiguration.dispose();
}
});
return control;
}
示例6: setCompareViewerInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
void setCompareViewerInput(int dataIndex) {
if (!fViewer.getControl().isDisposed()) {
MergeResult mergeResult = mergeResults.get(dataIndex);
fViewer.setInput(new DiffNode(
new DiffElementFromString(mergeResult.getUserPackagaJson()),
new DiffElementFromString(mergeResult.getFinalPackageJson())));
fViewer.refresh();
}
}
示例7: setCompareViewerInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
private void setCompareViewerInput(int dataIndex) {
if (fViewer.getControl().isDisposed())
return;
if (specChanges.isEmpty())
return;
SpecFile specChange = specChanges.get(dataIndex);
fViewer.setInput(new DiffNode(
new OriginalElementFromFile(specChange.getFile()),
new TargetElementFromString(specChange.getNewContent())));
fViewer.refresh();
}
示例8: saveChanges
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
public void saveChanges(IProgressMonitor pm) throws CoreException {
super.saveChanges(pm);
if (fRoot instanceof DiffNode) {
try {
commit(pm, (DiffNode) fRoot);
} finally {
setDirty(false);
}
}
}
示例9: prepareInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
initLabels();
MultipleSelectionNode left = new MultipleSelectionNode(localResourceNodes);
MultipleSelectionNode right = new MultipleSelectionNode(remoteResourceNodes);
Object differences = new StatusAwareDifferencer().findDifferences(false, monitor,null,null,left,right);
if (differences instanceof DiffNode) {
DiffNode diffNode = (DiffNode)differences;
IDiffElement[] children = diffNode.getChildren();
for (IDiffElement child : children) {
if (child instanceof DiffNode) {
DiffNode childDiffNode = (DiffNode)child;
if (childDiffNode.getLeft() == null && childDiffNode.getRight() instanceof ResourceEditionNode) {
diffNode.remove(child);
}
}
}
if (!diffNode.hasChildren()) {
return null;
}
}
for (IResource unaddedResource : unaddedResources) {
try {
SVNWorkspaceRoot.getSVNResourceFor(unaddedResource).revert();
} catch (Exception e) {}
}
fRoot = differences;
return differences;
}
示例10: prepareInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
@Override
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
CompareConfiguration cc = getCompareConfiguration();
cc.setRightEditable(false);
cc.setLeftEditable(false);
cc.setLeftLabel("original");
cc.setRightLabel("formatted Text");
return new DiffNode(left, right);
}
示例11: prepareInput
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
initLabels();
MultipleSelectionNode left = new MultipleSelectionNode(localResourceNodes);
MultipleSelectionNode right = new MultipleSelectionNode(remoteResourceNodes);
Object differences = new StatusAwareDifferencer().findDifferences(false, monitor,null,null,left,right);
if (differences instanceof DiffNode) {
DiffNode diffNode = (DiffNode)differences;
if (!diffNode.hasChildren()) {
return null;
}
}
fRoot = differences;
return differences;
}
示例12: initialSelection
import org.eclipse.compare.structuremergeviewer.DiffNode; //导入依赖的package包/类
/**
* Overridden to find and expand the first class.
*/
@Override
protected void initialSelection() {
Object firstClass= null;
Object o= getRoot();
if (o != null) {
Object[] children= getSortedChildren(o);
if (children != null && children.length > 0) {
for (int i= 0; i < children.length; i++) {
o= children[i];
Object[] sortedChildren= getSortedChildren(o);
if (sortedChildren != null && sortedChildren.length > 0) {
for (int j= 0; j < sortedChildren.length; j++) {
o= sortedChildren[j];
if (o instanceof DiffNode) {
DiffNode dn= (DiffNode) o;
ITypedElement e= dn.getId();
if (e instanceof JavaNode) {
JavaNode jn= (JavaNode) e;
int tc= jn.getTypeCode();
if (tc == JavaNode.CLASS || tc == JavaNode.INTERFACE) {
firstClass= dn;
}
}
}
}
}
}
}
}
if (firstClass != null)
expandToLevel(firstClass, 1);
else
expandToLevel(2);
}