Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-10-09 05:19:57 -0400
committerMikaël Barbero2013-10-11 10:22:32 -0400
commit60404a38e2841f3db703566e5284ae5b5b70117e (patch)
tree10d303819d7f7aebdc8b955b41d0982ccc0f485b /plugins/org.eclipse.emf.compare.ide.ui/src
parent9c11f16a8949834ab3d4032a9395a4c3e6bd80f5 (diff)
downloadorg.eclipse.emf.compare-60404a38e2841f3db703566e5284ae5b5b70117e.tar.gz
org.eclipse.emf.compare-60404a38e2841f3db703566e5284ae5b5b70117e.tar.xz
org.eclipse.emf.compare-60404a38e2841f3db703566e5284ae5b5b70117e.zip
Move INavigatable to its own class.
And only register it on EMFCompareStrutureMergeViewer's control and not EMFCompareDiffTreeViewer's tree. Change-Id: Ibd6abaa4e93cf4ed953cfa2af8e833040b583349
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui/src')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java255
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/Navigatable.java265
3 files changed, 269 insertions, 255 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java
index 9c36b7a28..cef6e56ce 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java
@@ -17,11 +17,7 @@ import static com.google.common.collect.Sets.newHashSet;
import static com.google.common.collect.Sets.newLinkedHashSet;
import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-import com.google.common.collect.UnmodifiableIterator;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
@@ -30,14 +26,11 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
-import java.util.ListIterator;
import java.util.Set;
import org.eclipse.compare.CompareViewerPane;
import org.eclipse.compare.CompareViewerSwitchingPane;
-import org.eclipse.compare.INavigatable;
import org.eclipse.compare.structuremergeviewer.DiffTreeViewer;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notifier;
@@ -82,10 +75,7 @@ import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.graphics.Color;
@@ -211,52 +201,6 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
requiredDiffColor = JFaceResources.getColorRegistry().get(REQUIRED_DIFF_COLOR);
unmergeableDiffColor = JFaceResources.getColorRegistry().get(UNMERGEABLE_DIFF_COLOR);
- INavigatable nav = new INavigatable() {
- public boolean selectChange(int flag) {
- ISelection selection = getSelection();
- TreeNode nextOrPrev = null;
- if (selection instanceof IStructuredSelection) {
- Object firstElement = ((IStructuredSelection)selection).getFirstElement();
- if (firstElement instanceof Adapter) {
- Notifier target = ((Adapter)firstElement).getTarget();
- if (target instanceof TreeNode) {
- TreeNode treeNode = (TreeNode)target;
- if (flag == INavigatable.NEXT_CHANGE) {
- nextOrPrev = getNextDiffNode(treeNode);
- } else if (flag == INavigatable.PREVIOUS_CHANGE) {
- nextOrPrev = getPrevDiffNode(treeNode);
- } else if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) {
- return true;
- }
- if (nextOrPrev != null) {
- StructuredSelection newSelection = new StructuredSelection(adapterFactory
- .adapt(nextOrPrev, ICompareInput.class));
- setSelection(newSelection);
- fireOpen(new OpenEvent(EMFCompareDiffTreeViewer.this, newSelection));
- }
- }
- }
- }
- return nextOrPrev == null;
- }
-
- public Object getInput() {
- return EMFCompareDiffTreeViewer.this.getInput();
- }
-
- public boolean openSelectedChange() {
- return true;
- }
-
- public boolean hasChange(int changeFlag) {
- if (changeFlag == INavigatable.NEXT_CHANGE || changeFlag == INavigatable.PREVIOUS_CHANGE) {
- return true;
- }
- return false;
- }
- };
- getTree().setData(INavigatable.NAVIGATOR_PROPERTY, nav);
-
configurationChangeListener = new EMFCompareConfigurationChangeListener() {
/**
* {@inheritDoc}
@@ -316,155 +260,11 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
}
/**
- * Returns, from the given TreeNode, the previous TreeNode that contains a diff.
- *
- * @param treeNode
- * the given TreeNode for which we want to find the previous.
- * @return the previous TreeNode that contains a diff.
- */
- private TreeNode getPrevDiffNode(TreeNode treeNode) {
- TreeNode previousNode = null;
- TreeNode parentNode = treeNode.getParent();
- if (parentNode != null) {
- List<TreeNode> children = getSortedTreeNodeChildren(
- adapterFactory.adapt(parentNode, ICompareInput.class)).reverse();
- int indexOfTreeNode = children.indexOf(treeNode);
- if (indexOfTreeNode == children.size() - 1) {
- if (IS_DIFF_TREE_NODE.apply(parentNode)) {
- previousNode = parentNode;
- } else {
- previousNode = getPrevDiffNode(parentNode);
- }
- } else {
- boolean stop = false;
- while (!stop) {
- if (children.size() > indexOfTreeNode + 1) {
- TreeNode prevSibling = children.get(indexOfTreeNode + 1);
- previousNode = getLastChildDiffNode(prevSibling);
- if (previousNode != null) {
- stop = true;
- } else if (IS_DIFF_TREE_NODE.apply(prevSibling)) {
- previousNode = prevSibling;
- stop = true;
- }
- indexOfTreeNode++;
- } else {
- previousNode = getPrevDiffNode(parentNode);
- stop = true;
- }
- }
- }
- }
- return previousNode;
- }
-
- /**
- * Returns, from the given TreeNode, the next TreeNode that contains a diff.
- *
- * @param treeNode
- * the given TreeNode for which we want to find the next.
- * @return the next TreeNode that contains a diff.
- */
- private TreeNode getNextDiffNode(TreeNode treeNode) {
- TreeNode next = getFirstChildDiffNode(treeNode);
- if (next == null) {
- TreeNode currentNode = treeNode;
- boolean stop = false;
- while (!stop && currentNode != null) {
- next = getNextSiblingDiffNode(currentNode);
- if (next == null) {
- currentNode = currentNode.getParent();
- } else {
- stop = true;
- }
- }
- }
- return next;
- }
-
- /**
- * Returns, from the given TreeNode, the next sibling TreeNode that contains a diff.
- *
- * @param treeNode
- * the given TreeNode for which we want to find the next sibling.
- * @return the next sibling TreeNode that contains a diff.
- */
- private TreeNode getNextSiblingDiffNode(TreeNode treeNode) {
- TreeNode next = null;
- TreeNode parent = treeNode.getParent();
- if (parent != null) {
- List<TreeNode> children = getSortedTreeNodeChildren(adapterFactory.adapt(parent,
- ICompareInput.class));
- int indexOfTreeNode = children.indexOf(treeNode);
- boolean stop = false;
- while (!stop) {
- if (children.size() > indexOfTreeNode + 1) {
- TreeNode nextSibling = children.get(indexOfTreeNode + 1);
- if (IS_DIFF_TREE_NODE.apply(nextSibling)) {
- next = nextSibling;
- } else {
- next = getFirstChildDiffNode(nextSibling);
- }
- if (next != null) {
- stop = true;
- }
- indexOfTreeNode++;
- } else {
- stop = true;
- }
- }
- }
- return next;
- }
-
- /**
- * Returns, from the given TreeNode, the first TreeNode child that contains a diff.
- *
- * @param treeNode
- * the given TreeNode for which we want to find the first child.
- * @return the first TreeNode child that contains a diff.
- */
- private TreeNode getFirstChildDiffNode(TreeNode treeNode) {
- UnmodifiableIterator<EObject> diffChildren = Iterators.filter(treeNode.eAllContents(),
- IS_DIFF_TREE_NODE);
- while (diffChildren.hasNext()) {
- TreeNode next = (TreeNode)diffChildren.next();
- if (!JFaceUtil.isFiltered(this, adapterFactory.adapt(next, ICompareInput.class), adapterFactory
- .adapt(next.getParent(), ICompareInput.class))) {
- return next;
- }
- }
- return null;
- }
-
- /**
- * Returns, from the given TreeNode, the last TreeNode child that contains a diff.
- *
- * @param treeNode
- * the given TreeNode for which we want to find the last child.
- * @return the last TreeNode child that contains a diff.
- */
- private TreeNode getLastChildDiffNode(TreeNode treeNode) {
- UnmodifiableIterator<EObject> diffChildren = Iterators.filter(treeNode.eAllContents(),
- IS_DIFF_TREE_NODE);
- List<EObject> l = Lists.newArrayList(diffChildren);
- ListIterator<EObject> li = l.listIterator(l.size());
- while (li.hasPrevious()) {
- TreeNode prev = (TreeNode)li.previous();
- if (!JFaceUtil.isFiltered(this, adapterFactory.adapt(prev, ICompareInput.class), adapterFactory
- .adapt(prev.getParent(), ICompareInput.class))) {
- return prev;
- }
- }
- return null;
- }
-
- /**
* A predicate that checks if the given input is a TreeNode that contains a diff.
*
* @return true, if the given input is a TreeNode that contains a diff, false otherwise.
*/
- private static Predicate<EObject> IS_DIFF_TREE_NODE = new Predicate<EObject>() {
+ static Predicate<EObject> IS_DIFF_TREE_NODE = new Predicate<EObject>() {
public boolean apply(EObject t) {
return t instanceof TreeNode && ((TreeNode)t).getData() instanceof Diff;
}
@@ -473,28 +273,6 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
private final EMFCompareConfigurationChangeListener configurationChangeListener;
/**
- * Returns the sorted and filtered set of TreeNode children of the given element.
- *
- * @param treeNodeAdapter
- * the given TreeNode adapter.
- * @return the sorted and filtered set of TreeNode children of the given element.
- */
- private ImmutableList<TreeNode> getSortedTreeNodeChildren(Adapter treeNodeAdapter) {
- List<TreeNode> treeNodeChildren = Lists.newArrayList();
- Object[] sortedChildren = getSortedChildren(treeNodeAdapter);
- for (Object object : sortedChildren) {
- if (object instanceof Adapter) {
- Notifier target = ((Adapter)object).getTarget();
- if (target instanceof TreeNode) {
- treeNodeChildren.add((TreeNode)target);
- }
- }
- }
- return ImmutableList.copyOf(treeNodeChildren);
-
- }
-
- /**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.StructuredViewer#getComparator()
@@ -582,40 +360,11 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
public boolean isExpandable(Object parent) {
if (hasFilters()) {
// workaround for 65762
- return hasFilteredChildren(parent);
+ return getFilteredChildren(parent).length > 0;
}
return super.isExpandable(parent);
}
- /**
- * Public method to test if a element has any children that passed the filters
- *
- * @param parent
- * the element to test
- * @return return <code>true</code> if the element has at least a child that passed the filters
- */
- public final boolean hasFilteredChildren(Object parent) {
- Object[] rawChildren = getRawChildren(parent);
- return containsNonFiltered(rawChildren, parent);
- }
-
- private boolean containsNonFiltered(Object[] elements, Object parent) {
- if (elements.length == 0) {
- return false;
- }
- if (!hasFilters()) {
- return true;
- }
- ViewerFilter[] filters = getFilters();
- for (int i = 0; i < elements.length; i++) {
- Object object = elements[i];
- if (!JFaceUtil.isFiltered(this, object, parent)) {
- return true;
- }
- }
- return false;
- }
-
public void refreshAfterDiff(Object root) {
if (getControl().isDisposed()) {
return;
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
index 40e392596..2b75690e8 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
@@ -208,8 +208,8 @@ public class EMFCompareStructureMergeViewer extends AbstractViewerWrapper implem
control.setLayoutData(data);
diffTreeViewer = new EMFCompareDiffTreeViewer(control, fAdapterFactory, getCompareConfiguration());
setViewer(diffTreeViewer);
- control.setData(INavigatable.NAVIGATOR_PROPERTY, diffTreeViewer.getControl().getData(
- INavigatable.NAVIGATOR_PROPERTY));
+ INavigatable nav = new Navigatable(fAdapterFactory, diffTreeViewer);
+ control.setData(INavigatable.NAVIGATOR_PROPERTY, nav);
control.setData(CompareUI.COMPARE_VIEWER_TITLE, "Model differences");
diffTreeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, true);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/Navigatable.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/Navigatable.java
new file mode 100644
index 000000000..b00f5c618
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/Navigatable.java
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+import com.google.common.collect.UnmodifiableIterator;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.compare.INavigatable;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util.DynamicObject;
+import org.eclipse.emf.compare.ide.ui.internal.util.JFaceUtil;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.tree.TreeNode;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+
+/**
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class Navigatable implements INavigatable {
+ /**
+ *
+ */
+ private final AdapterFactory adapterFactory;
+
+ private final StructuredViewer viewer;
+
+ private final DynamicObject dynamicObject;
+
+ /**
+ * @param adapterFactory
+ */
+ public Navigatable(AdapterFactory adapterFactory, StructuredViewer viewer) {
+ this.adapterFactory = adapterFactory;
+ this.viewer = viewer;
+ this.dynamicObject = new DynamicObject(viewer);
+ }
+
+ public boolean selectChange(int flag) {
+ TreeNode nextOrPrev = null;
+ Object firstElement = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
+ if (firstElement instanceof Adapter) {
+ Notifier target = ((Adapter)firstElement).getTarget();
+ if (target instanceof TreeNode) {
+ TreeNode treeNode = (TreeNode)target;
+ if (flag == INavigatable.NEXT_CHANGE) {
+ nextOrPrev = getNextDiffNode(treeNode);
+ } else if (flag == INavigatable.PREVIOUS_CHANGE) {
+ nextOrPrev = getPrevDiffNode(treeNode);
+ } else if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) {
+ return true;
+ }
+ if (nextOrPrev != null) {
+ StructuredSelection newSelection = new StructuredSelection(adapterFactory.adapt(
+ nextOrPrev, ICompareInput.class));
+ viewer.setSelection(newSelection);
+ dynamicObject
+ .invoke("fireOpen", new Class<?>[] {OpenEvent.class, }, new OpenEvent(viewer, newSelection)); //$NON-NLS-1$
+ }
+ }
+ }
+ return nextOrPrev == null;
+ }
+
+ public Object getInput() {
+ return viewer.getInput();
+ }
+
+ public boolean openSelectedChange() {
+ return true;
+ }
+
+ public boolean hasChange(int changeFlag) {
+ if (changeFlag == INavigatable.NEXT_CHANGE || changeFlag == INavigatable.PREVIOUS_CHANGE) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns, from the given TreeNode, the previous TreeNode that contains a diff.
+ *
+ * @param treeNode
+ * the given TreeNode for which we want to find the previous.
+ * @return the previous TreeNode that contains a diff.
+ */
+ private TreeNode getPrevDiffNode(TreeNode treeNode) {
+ TreeNode previousNode = null;
+ TreeNode parentNode = treeNode.getParent();
+ if (parentNode != null) {
+ List<TreeNode> children = getSortedTreeNodeChildren(
+ adapterFactory.adapt(parentNode, ICompareInput.class)).reverse();
+ int indexOfTreeNode = children.indexOf(treeNode);
+ if (indexOfTreeNode == children.size() - 1) {
+ if (EMFCompareDiffTreeViewer.IS_DIFF_TREE_NODE.apply(parentNode)) {
+ previousNode = parentNode;
+ } else {
+ previousNode = getPrevDiffNode(parentNode);
+ }
+ } else {
+ boolean stop = false;
+ while (!stop) {
+ if (children.size() > indexOfTreeNode + 1) {
+ TreeNode prevSibling = children.get(indexOfTreeNode + 1);
+ previousNode = getLastChildDiffNode(prevSibling);
+ if (previousNode != null) {
+ stop = true;
+ } else if (EMFCompareDiffTreeViewer.IS_DIFF_TREE_NODE.apply(prevSibling)) {
+ previousNode = prevSibling;
+ stop = true;
+ }
+ indexOfTreeNode++;
+ } else {
+ previousNode = getPrevDiffNode(parentNode);
+ stop = true;
+ }
+ }
+ }
+ }
+ return previousNode;
+ }
+
+ /**
+ * Returns, from the given TreeNode, the next TreeNode that contains a diff.
+ *
+ * @param treeNode
+ * the given TreeNode for which we want to find the next.
+ * @return the next TreeNode that contains a diff.
+ */
+ private TreeNode getNextDiffNode(TreeNode treeNode) {
+ TreeNode next = getFirstChildDiffNode(treeNode);
+ if (next == null) {
+ TreeNode currentNode = treeNode;
+ boolean stop = false;
+ while (!stop && currentNode != null) {
+ next = getNextSiblingDiffNode(currentNode);
+ if (next == null) {
+ currentNode = currentNode.getParent();
+ } else {
+ stop = true;
+ }
+ }
+ }
+ return next;
+ }
+
+ /**
+ * Returns, from the given TreeNode, the next sibling TreeNode that contains a diff.
+ *
+ * @param treeNode
+ * the given TreeNode for which we want to find the next sibling.
+ * @return the next sibling TreeNode that contains a diff.
+ */
+ private TreeNode getNextSiblingDiffNode(TreeNode treeNode) {
+ TreeNode next = null;
+ TreeNode parent = treeNode.getParent();
+ if (parent != null) {
+ List<TreeNode> children = getSortedTreeNodeChildren(adapterFactory.adapt(parent,
+ ICompareInput.class));
+ int indexOfTreeNode = children.indexOf(treeNode);
+ boolean stop = false;
+ while (!stop) {
+ if (children.size() > indexOfTreeNode + 1) {
+ TreeNode nextSibling = children.get(indexOfTreeNode + 1);
+ if (EMFCompareDiffTreeViewer.IS_DIFF_TREE_NODE.apply(nextSibling)) {
+ next = nextSibling;
+ } else {
+ next = getFirstChildDiffNode(nextSibling);
+ }
+ if (next != null) {
+ stop = true;
+ }
+ indexOfTreeNode++;
+ } else {
+ stop = true;
+ }
+ }
+ }
+ return next;
+ }
+
+ /**
+ * Returns, from the given TreeNode, the first TreeNode child that contains a diff.
+ *
+ * @param treeNode
+ * the given TreeNode for which we want to find the first child.
+ * @return the first TreeNode child that contains a diff.
+ */
+ private TreeNode getFirstChildDiffNode(TreeNode treeNode) {
+ UnmodifiableIterator<EObject> diffChildren = Iterators.filter(treeNode.eAllContents(),
+ EMFCompareDiffTreeViewer.IS_DIFF_TREE_NODE);
+ while (diffChildren.hasNext()) {
+ TreeNode next = (TreeNode)diffChildren.next();
+ if (!JFaceUtil.isFiltered(viewer, adapterFactory.adapt(next, ICompareInput.class), adapterFactory
+ .adapt(next.getParent(), ICompareInput.class))) {
+ return next;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns, from the given TreeNode, the last TreeNode child that contains a diff.
+ *
+ * @param treeNode
+ * the given TreeNode for which we want to find the last child.
+ * @return the last TreeNode child that contains a diff.
+ */
+ private TreeNode getLastChildDiffNode(TreeNode treeNode) {
+ UnmodifiableIterator<EObject> diffChildren = Iterators.filter(treeNode.eAllContents(),
+ EMFCompareDiffTreeViewer.IS_DIFF_TREE_NODE);
+ List<EObject> l = Lists.newArrayList(diffChildren);
+ ListIterator<EObject> li = l.listIterator(l.size());
+ while (li.hasPrevious()) {
+ TreeNode prev = (TreeNode)li.previous();
+ if (!JFaceUtil.isFiltered(viewer, adapterFactory.adapt(prev, ICompareInput.class), adapterFactory
+ .adapt(prev.getParent(), ICompareInput.class))) {
+ return prev;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the sorted and filtered set of TreeNode children of the given element.
+ *
+ * @param treeNodeAdapter
+ * the given TreeNode adapter.
+ * @return the sorted and filtered set of TreeNode children of the given element.
+ */
+ private ImmutableList<TreeNode> getSortedTreeNodeChildren(Adapter treeNodeAdapter) {
+ List<TreeNode> treeNodeChildren = Lists.newArrayList();
+ Object[] sortedChildren = (Object[])dynamicObject.invoke("getSortedChildren", //$NON-NLS-1$
+ new Class<?>[] {Object.class, }, treeNodeAdapter);
+ for (Object object : sortedChildren) {
+ if (object instanceof Adapter) {
+
+ Notifier target = ((Adapter)object).getTarget();
+ if (target instanceof TreeNode) {
+ treeNodeChildren.add((TreeNode)target);
+ }
+ }
+ }
+ return ImmutableList.copyOf(treeNodeChildren);
+
+ }
+}

Back to the top