Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-03-22 09:45:45 -0400
committerlgoubet2019-03-22 09:45:45 -0400
commit28a35cf425a6cc97cd851303fe24266e1b3f04ae (patch)
treebeb16c9515ddd97be514ce90e396395411e51cf3
parent95df139d16dd7c279d019611a81f90ab485f8843 (diff)
downloadorg.eclipse.emf.compare-28a35cf425a6cc97cd851303fe24266e1b3f04ae.tar.gz
org.eclipse.emf.compare-28a35cf425a6cc97cd851303fe24266e1b3f04ae.tar.xz
org.eclipse.emf.compare-28a35cf425a6cc97cd851303fe24266e1b3f04ae.zip
Make sure we hook the UI when users provide a precomputed comparison
In the case of a comparison being reused across multiple SMV (comparison dialog, custom comparison UI, ...), the EMF Compare UI still needs its adapters hooked to the comparison. Change-Id: I13b7d9f310040f913af2279c17ee2d011ef8429c
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java20
1 files changed, 18 insertions, 2 deletions
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 a5e35c0a1..9b083bb08 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
@@ -1440,8 +1440,10 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
initToolbar(monitor);
} else if (input instanceof IComparisonProvider) {
resourceSetShouldBeDisposed = false;
- compareInputChanged(((IComparisonProvider)input).getComparisonScope(monitor),
- ((IComparisonProvider)input).getComparison(monitor), monitor);
+ Comparison comparison = ((IComparisonProvider)input).getComparison(monitor);
+ compareInputChanged(((IComparisonProvider)input).getComparisonScope(monitor), comparison,
+ monitor);
+ hookAdapters(input, comparison);
initToolbar(monitor);
} else {
resourceSetShouldBeDisposed = true;
@@ -1575,6 +1577,20 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
* @param compareResult
*/
private void hookAdapters(final ICompareInput input, final Comparison compareResult) {
+ // It is now possible for users to provide a pre-computed comparison to the compare editor and re-use
+ // that comparison across multiple SMV. We need to cleanup previous hooks.
+ Iterator<Adapter> adapterIt = compareResult.eAdapters().iterator();
+ while (adapterIt.hasNext()) {
+ Adapter adapter = adapterIt.next();
+ if (adapter instanceof ForwardingCompareInputAdapter) {
+ adapterIt.remove();
+ } else if (adapter instanceof SideLabelProvider) {
+ adapterIt.remove();
+ } else if (adapter instanceof MergeDataImpl) {
+ adapterIt.remove();
+ }
+ }
+
compareResult.eAdapters().add(new ForwardingCompareInputAdapter(input));
// Thanks to
// org.eclipse.team.internal.ui.mapping.ResourceCompareInputChangeNotifier$CompareInputLabelProvider

Back to the top