Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-10-09 05:18:14 -0400
committerMikaël Barbero2013-10-11 10:22:32 -0400
commit9c11f16a8949834ab3d4032a9395a4c3e6bd80f5 (patch)
tree5bd4b54530e791a8eca495ccd8492907c0a4b9b8 /plugins/org.eclipse.emf.compare.ide.ui/src
parent4d2bf1963c8584eb7ab4200e2c9679d2134053fe (diff)
downloadorg.eclipse.emf.compare-9c11f16a8949834ab3d4032a9395a4c3e6bd80f5.tar.gz
org.eclipse.emf.compare-9c11f16a8949834ab3d4032a9395a4c3e6bd80f5.tar.xz
org.eclipse.emf.compare-9c11f16a8949834ab3d4032a9395a4c3e6bd80f5.zip
Externalize isFiltered utility method.
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.java35
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/JFaceUtil.java40
2 files changed, 47 insertions, 28 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 24602540b..9c36b7a28 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
@@ -56,6 +56,7 @@ import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.Merg
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.SaveComparisonModelAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.SelectNextDiffAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.SelectPreviousDiffAction;
+import org.eclipse.emf.compare.ide.ui.internal.util.JFaceUtil;
import org.eclipse.emf.compare.internal.merge.MergeMode;
import org.eclipse.emf.compare.internal.utils.DiffUtil;
import org.eclipse.emf.compare.merge.IMerger;
@@ -428,8 +429,8 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
IS_DIFF_TREE_NODE);
while (diffChildren.hasNext()) {
TreeNode next = (TreeNode)diffChildren.next();
- if (!isFiltered(adapterFactory.adapt(next, ICompareInput.class), adapterFactory.adapt(next
- .getParent(), ICompareInput.class), getFilters())) {
+ if (!JFaceUtil.isFiltered(this, adapterFactory.adapt(next, ICompareInput.class), adapterFactory
+ .adapt(next.getParent(), ICompareInput.class))) {
return next;
}
}
@@ -450,8 +451,8 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
ListIterator<EObject> li = l.listIterator(l.size());
while (li.hasPrevious()) {
TreeNode prev = (TreeNode)li.previous();
- if (!isFiltered(adapterFactory.adapt(prev, ICompareInput.class), adapterFactory.adapt(prev
- .getParent(), ICompareInput.class), getFilters())) {
+ if (!JFaceUtil.isFiltered(this, adapterFactory.adapt(prev, ICompareInput.class), adapterFactory
+ .adapt(prev.getParent(), ICompareInput.class))) {
return prev;
}
}
@@ -608,28 +609,7 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
ViewerFilter[] filters = getFilters();
for (int i = 0; i < elements.length; i++) {
Object object = elements[i];
- if (!isFiltered(object, parent, filters)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * All element filter tests must go through this method. Can be overridden by subclasses.
- *
- * @param object
- * the object to filter
- * @param parent
- * the parent
- * @param filters
- * the filters to apply
- * @return true if the element is filtered
- */
- protected boolean isFiltered(Object object, Object parent, ViewerFilter[] filters) {
- for (int i = 0; i < filters.length; i++) {
- ViewerFilter filter = filters[i];
- if (!filter.select(this, parent, object)) {
+ if (!JFaceUtil.isFiltered(this, object, parent)) {
return true;
}
}
@@ -670,10 +650,9 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
* @return
*/
private void getMatchCount(ITreeContentProvider cp, Object[] elements, Set<Diff> diffs) {
- ViewerFilter[] filters = getFilters();
for (int j = 0; j < elements.length; j++) {
Object element = elements[j];
- if (!isFiltered(element, null, filters) && element instanceof Adapter) {
+ if (!JFaceUtil.isFiltered(this, element, null) && element instanceof Adapter) {
Notifier target = ((Adapter)element).getTarget();
if (target instanceof TreeNode) {
TreeNode treeNode = (TreeNode)target;
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/JFaceUtil.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/JFaceUtil.java
new file mode 100644
index 000000000..0acb9c46a
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/util/JFaceUtil.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.util;
+
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class JFaceUtil {
+
+ /**
+ * All element filter tests must go through this method.
+ *
+ * @param viewer
+ * the viewer
+ * @param object
+ * the object to filter
+ * @param parent
+ * the parent
+ * @return true if the element is filtered
+ */
+ public static boolean isFiltered(StructuredViewer viewer, Object object, Object parent) {
+ for (ViewerFilter filter : viewer.getFilters()) {
+ if (!filter.select(viewer, parent, object)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}

Back to the top