Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-10-08 14:39:51 -0400
committerMikaël Barbero2013-10-11 10:22:31 -0400
commite2659dd7f65d3a81a487504d15404dcbd2b2590b (patch)
tree4855d8fbf95805699331d56577bc73bdc0cb68b1 /plugins/org.eclipse.emf.compare.ide.ui/src
parentcf360198078681831e570a80a4362dfe4e0f5eaf (diff)
downloadorg.eclipse.emf.compare-e2659dd7f65d3a81a487504d15404dcbd2b2590b.tar.gz
org.eclipse.emf.compare-e2659dd7f65d3a81a487504d15404dcbd2b2590b.tar.xz
org.eclipse.emf.compare-e2659dd7f65d3a81a487504d15404dcbd2b2590b.zip
Avoid the refresh of structure merge viewer to collapse the tree.
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/CompareInputComparer.java95
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java16
2 files changed, 1 insertions, 110 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputComparer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputComparer.java
deleted file mode 100644
index 320fc4048..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareInputComparer.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.jface.viewers.IElementComparer;
-
-/**
- * We'll use this in order to compare our diff nodes through their target's {@link Object#equals(Object)}
- * instead of the nodes' own equals (which only resorts to instance equality).
- * <p>
- * Note that this will fall back to the default behavior for anything that is not an
- * {@link AbstractEDiffElement}.
- * </p>
- * <p>
- * This class most likely breaks the implicit contract of equals() since we are comparing AbstractEDiffElement
- * through two different means : if we have a target, use it... otherwise fall back to instance equality. Both
- * equals() and hashCode() follow this same rule.
- * </p>
- *
- * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
- */
-public class CompareInputComparer implements IElementComparer {
- /** Our delegate comparer. May be {@code null}. */
- private IElementComparer delegate;
-
- /**
- * Constructs this comparer given the previous one that was installed on this viewer.
- *
- * @param delegate
- * The comparer to which we should delegate our default behavior. May be {@code null}.
- */
- public CompareInputComparer(IElementComparer delegate) {
- this.delegate = delegate;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IElementComparer#equals(java.lang.Object, java.lang.Object)
- */
- public boolean equals(Object a, Object b) {
- final boolean equal;
- if (a instanceof Adapter && b instanceof Adapter) {
- final Notifier targetA = ((Adapter)a).getTarget();
- if (targetA == null) {
- // Fall back to default behavior
- equal = a.equals(b);
- } else {
- equal = targetA.equals(((Adapter)b).getTarget());
- }
- } else if (delegate != null) {
- equal = delegate.equals(a, b);
- } else if (a != null) {
- equal = a.equals(b);
- } else {
- equal = b == null;
- }
- return equal;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IElementComparer#hashCode(java.lang.Object)
- */
- public int hashCode(Object element) {
- final int hashCode;
- if (element instanceof Adapter) {
- final Notifier target = ((Adapter)element).getTarget();
- if (target == null) {
- // Fall back to default behavior
- hashCode = element.hashCode();
- } else {
- hashCode = target.hashCode();
- }
- } else if (delegate != null) {
- hashCode = delegate.hashCode(element);
- } else if (element != null) {
- hashCode = element.hashCode();
- } else {
- hashCode = 0;
- }
- return hashCode;
- }
-}
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 c36001ba0..24602540b 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
@@ -78,7 +78,6 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.IElementComparer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -198,9 +197,6 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
};
getControl().addListener(SWT.EraseItem, fEraseItemListener);
- // Wrap the defined comparer in our own.
- setComparer(new CompareInputComparer(super.getComparer()));
-
if (eventBus == null) {
eventBus = new EventBus();
eventBus.register(this);
@@ -315,6 +311,7 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
}
};
configuration.addChangeListener(configurationChangeListener);
+ setUseHashlookup(true);
}
/**
@@ -694,17 +691,6 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
/**
* {@inheritDoc}
*
- * @see org.eclipse.jface.viewers.StructuredViewer#setComparer(org.eclipse.jface.viewers.IElementComparer)
- */
- @Override
- public void setComparer(IElementComparer comparer) {
- // Wrap this new comparer in our own
- super.setComparer(new CompareInputComparer(comparer));
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.eclipse.compare.structuremergeviewer.DiffTreeViewer#createToolItems(org.eclipse.jface.action.ToolBarManager)
*/
@Override

Back to the top