Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-02-08 09:33:36 -0500
committerlgoubet2019-02-11 08:45:22 -0500
commit4b3517a258e7d0e7b489cdea9557bface4abcb34 (patch)
tree91d10536f4b71ffe93d5c15b591ddf393cd65841
parenta309ac1e461e8f2ae30dbbc9e5918ba9e12669ad (diff)
downloadorg.eclipse.emf.compare-4b3517a258e7d0e7b489cdea9557bface4abcb34.tar.gz
org.eclipse.emf.compare-4b3517a258e7d0e7b489cdea9557bface4abcb34.tar.xz
org.eclipse.emf.compare-4b3517a258e7d0e7b489cdea9557bface4abcb34.zip
Allow clients to provide pre-computed comparisons to the compare UI
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java25
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/IComparisonProvider.java27
2 files changed, 43 insertions, 9 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 cf5e05b1f..c7669677f 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
@@ -1249,8 +1249,8 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
}
}
- void compareInputChanged(CompareInputAdapter input, IProgressMonitor monitor) {
- compareInputChanged(null, (Comparison)input.getComparisonObject(), monitor);
+ void compareInputChanged(Comparison input, IProgressMonitor monitor) {
+ compareInputChanged(null, input, monitor);
}
void compareInputChanged(ComparisonScopeInput input, IProgressMonitor monitor) {
@@ -1274,12 +1274,6 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
compareConfiguration.setMergePreviewMode(null);
}
- // setup defaults
- if (compareConfiguration.getEditingDomain() == null) {
- ICompareEditingDomain domain = EMFCompareEditingDomain.create(comparisonScope.getLeft(),
- comparisonScope.getRight(), comparisonScope.getOrigin());
- compareConfiguration.setEditingDomain(domain);
- }
if (comparator == null) {
Builder builder = EMFCompare.builder();
EMFCompareBuilderConfigurator.createDefault().configure(builder);
@@ -1311,6 +1305,13 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
if (!getControl().isDisposed() && !monitor.isCanceled()) { // guard against disposal
final EMFCompareConfiguration config = getCompareConfiguration();
+ // setup defaults
+ if (config.getEditingDomain() == null) {
+ ICompareEditingDomain domain = EMFCompareEditingDomain.create(scope.getLeft(),
+ scope.getRight(), scope.getOrigin());
+ config.setEditingDomain(domain);
+ }
+
ComposedAdapterFactory oldAdapterFactory = fAdapterFactory;
// re-initialize adapter factory due to new comparison
fAdapterFactory = initAdapterFactory(comparison);
@@ -1421,12 +1422,18 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
if (input != null && !monitor.isCanceled()) {
if (input instanceof CompareInputAdapter) {
resourceSetShouldBeDisposed = false;
- compareInputChanged((CompareInputAdapter)input, monitor);
+ CompareInputAdapter adapter = (CompareInputAdapter)input;
+ compareInputChanged((Comparison)adapter.getComparisonObject(), monitor);
initToolbar(monitor);
} else if (input instanceof ComparisonScopeInput) {
resourceSetShouldBeDisposed = false;
compareInputChanged((ComparisonScopeInput)input, monitor);
initToolbar(monitor);
+ } else if (input instanceof IComparisonProvider) {
+ resourceSetShouldBeDisposed = false;
+ compareInputChanged(((IComparisonProvider)input).getComparisonScope(monitor),
+ ((IComparisonProvider)input).getComparison(monitor), monitor);
+ initToolbar(monitor);
} else {
resourceSetShouldBeDisposed = true;
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/IComparisonProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/IComparisonProvider.java
new file mode 100644
index 000000000..a2646c116
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/IComparisonProvider.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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.core.runtime.IProgressMonitor;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+
+/**
+ * Specific comparison input that can be used to directly provide a pre-computed Comparison to the EMF Compare
+ * UI.
+ *
+ * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
+ */
+public interface IComparisonProvider {
+ IComparisonScope getComparisonScope(IProgressMonitor monitor);
+
+ Comparison getComparison(IProgressMonitor monitor);
+}

Back to the top