org.eclipse.compare.structuremergeviewer.DiffNode Java Examples
The following examples show how to use
org.eclipse.compare.structuremergeviewer.DiffNode.
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 |
@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: SpecComparePage.java From n4js with Eclipse Public License 1.0 | 6 votes |
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; }
Example #3
Source File: SVNLocalCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } } }
Example #4
Source File: SVNLocalBaseCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } } }
Example #5
Source File: SVNCompareRevisionsInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * 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 #6
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 #7
Source File: SVNLocalCompareSummaryInput.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } } }
Example #8
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public Viewer createDiffViewer(final Composite parent) { viewer = new DiffTreeViewer(parent, getCompareConfiguration()); viewer.addOpenListener(new IOpenListener() { @Override public void open(final OpenEvent event) { final IStructuredSelection sel = (IStructuredSelection) event.getSelection(); final DiffNode obj = (DiffNode) sel.getFirstElement(); obj.setDontExpand(false); } }); viewer.setFilters(getFilters()); viewer.setLabelProvider(new DiffTreeLabelProvider()); viewer.setContentProvider(new BonitaScriptRefactoringContentProvider()); viewer.setInput(root); viewer.expandAll(); return viewer; }
Example #10
Source File: DiffTreeLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void update(ViewerCell cell) { StyledString styledString = new StyledString(); DiffNode node = (DiffNode)cell.getElement(); if (node.getLeft()!=null){ styledString.append(getText(cell.getElement()),boldgreen); } else { styledString.append(getText(cell.getElement())); } cell.setText(styledString.getString()); cell.setImage(getImage(cell.getElement())) ; cell.setStyleRanges(styledString.getStyleRanges()); }
Example #11
Source File: AbapGitCompareInput.java From ADT_Frontend with MIT License | 5 votes |
@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 #12
Source File: DiffTreeLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public String getText(Object element) { if (element instanceof DiffNode){ DiffNode node = ((DiffNode)element); if (node.getLeft()!=null){ return node.getName(); } else { return node.getAncestor().getName(); } } return null; }
Example #13
Source File: DiffTreeLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Image getImage(Object element) { if (element instanceof DiffNode){ DiffNode node = ((DiffNode)element); if (node.getLeft()!=null){ return node.getImage(); } else { return node.getAncestor().getImage(); } } return null; }
Example #14
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private boolean insertParentNode(final DiffNode nodeToInsert) { final List<DiffNode> nodes = new ArrayList<DiffNode>(); getAllNodes(nodes, root); for (final DiffNode node : nodes) { if (node.getAncestor() != null && ((EObjectNode) node.getAncestor()).getElement() .equals(((EObjectNode) nodeToInsert.getAncestor()).getElement())) { addChildrenToParent(node, nodeToInsert.getChildren()); return true; } } return false; }
Example #15
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void getAllNodes(final List<DiffNode> nodes, final DiffNode root) { if (root.hasChildren()) { nodes.addAll((Collection<? extends DiffNode>) Arrays.asList(root.getChildren())); for (final IDiffElement child : root.getChildren()) { getAllNodes(nodes, (DiffNode) child); } } }
Example #16
Source File: BonitaScriptRefactoringContentProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Object[] getChildren(Object parentElement) { if (((DiffNode) parentElement).hasChildren()) { return ((DiffNode) parentElement).getChildren(); } return null; }
Example #17
Source File: BonitaScriptRefactoringContentProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Object[] getElements(Object inputElement) { if (inputElement instanceof DiffNode) { return ((DiffNode) inputElement).getChildren(); } return null; }
Example #18
Source File: DuplicatedCode.java From JDeodorant with MIT License | 5 votes |
@Override protected Object prepareInput(IProgressMonitor pm) { CompareItem firstText = new CompareItem("First", this.left); CompareItem secondText = new CompareItem("Second", this.right); return new DiffNode(firstText, secondText); }
Example #19
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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); }
Example #20
Source File: SVNLocalCompareSummaryInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void saveChanges(IProgressMonitor pm) throws CoreException { super.saveChanges(pm); if (fRoot instanceof DiffNode) { try { commit(pm, (DiffNode) fRoot); } finally { setDirty(false); } } }
Example #21
Source File: SVNLocalBaseCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void saveChanges(IProgressMonitor pm) throws CoreException { super.saveChanges(pm); if (fRoot instanceof DiffNode) { try { commit(pm, (DiffNode) fRoot); } finally { setDirty(false); } } }
Example #22
Source File: SVNLocalBaseCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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; }
Example #23
Source File: SVNLocalCompareInput.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void saveChanges(IProgressMonitor pm) throws CoreException { super.saveChanges(pm); if (fRoot instanceof DiffNode) { try { commit(pm, (DiffNode) fRoot); } finally { setDirty(false); } } }
Example #24
Source File: DatastoreIndexesUpdatedStatusHandler.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override protected ICompareInput prepareCompareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { CompareConfiguration cc = getCompareConfiguration(); cc.setLeftEditable(true); cc.setRightEditable(false); cc.setLeftLabel(source.getName()); cc.setLeftImage(CompareUI.getImage(source)); cc.setRightLabel(generatedUpdate.getName()); cc.setRightImage(CompareUI.getImage(source)); // same type ITypedElement left = SaveableCompareEditorInput.createFileElement(source); ITypedElement right = new LocalDiskContent(generatedUpdate); return new DiffNode(left, right); }
Example #25
Source File: SpecComparePage.java From n4js with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #26
Source File: BonitaScriptRefactoringContentProvider.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public boolean hasChildren(Object element) { final int length = ((DiffNode) element).getChildren().length; return length != 0; }
Example #27
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public DiffNode getRoot() { return root; }
Example #28
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public void setRoot(final DiffNode root) { this.root = root; }
Example #29
Source File: BonitaCompareEditorInput.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void addChildrenToParent(final DiffNode parent, final IDiffElement[] children) { for (final IDiffElement child : children) { parent.add(child); } }