Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2016-10-20 15:32:04 +0000
committerAxel Richard2016-10-21 07:24:51 +0000
commit99e8fb56b9bab8f8f58ba0b766b0b5e7132b9d6f (patch)
treecf3c043cdd40da81322cc823577d3f37b1a04a68
parentd8af5faeb2bff1a0658af54957deb7012c7e4b0c (diff)
downloadorg.eclipse.emf.compare-99e8fb56b9bab8f8f58ba0b766b0b5e7132b9d6f.tar.gz
org.eclipse.emf.compare-99e8fb56b9bab8f8f58ba0b766b0b5e7132b9d6f.tar.xz
org.eclipse.emf.compare-99e8fb56b9bab8f8f58ba0b766b0b5e7132b9d6f.zip
[501569] The cascading filter does not hide merged cascading diffs
Add new adapter (MatchOfContainmentDiffAdapter) to Matches related to containment diff. Use this adapter to fix bug 501569 on the cascading filter. Bug: 501569 Change-Id: Ie07bf3be141b656ca53f526960cdb1ff9cf0b2f4 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java3
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/MatchOfContainmentReferenceChangeAdapterTest.java74
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/MatchOfContainmentReferenceChangeAdapterTestData.java33
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/left.ecore9
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/right.ecore6
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java4
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/filters/impl/CascadingDifferencesFilter.java24
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java78
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/MatchOfContainmentReferenceChangeAdapter.java61
10 files changed, 274 insertions, 19 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 f07f26307..9c2a507c4 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
@@ -120,6 +120,7 @@ import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.Stru
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.impl.CascadingDifferencesFilter;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.StructureMergeViewerGrouper;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeItemProviderAdapterFactorySpec;
+import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.match.MatchOfContainmentReferenceChangeProcessor;
import org.eclipse.emf.compare.rcp.ui.internal.util.SWTUtil;
import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.filters.IDifferenceFilterChange;
import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroup;
@@ -1208,6 +1209,8 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
labelProvider.getRightImage(input));
compareResult.eAdapters().add(sideLabelProvider);
}
+ // Bug 501569: The cascading filter does not hide merged cascading diffs
+ new MatchOfContainmentReferenceChangeProcessor().execute(compareResult);
}
/**
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/MatchOfContainmentReferenceChangeAdapterTest.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/MatchOfContainmentReferenceChangeAdapterTest.java
new file mode 100644
index 000000000..d565df9dc
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/MatchOfContainmentReferenceChangeAdapterTest.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.rcp.ui.tests.structuremergeviewer.match;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.EMFCompare.Builder;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.match.MatchOfContainmentReferenceChangeAdapter;
+import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
+import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.match.MatchOfContainmentReferenceChangeProcessor;
+import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.match.data.MatchOfContainmentReferenceChangeAdapterTestData;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.junit.Test;
+
+/**
+ * Tests for {@link MatchOfContainmentReferenceChangeAdapter}.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+@SuppressWarnings("restriction")
+public class MatchOfContainmentReferenceChangeAdapterTest {
+
+ private static MatchOfContainmentReferenceChangeAdapterTestData inputData = new MatchOfContainmentReferenceChangeAdapterTestData();
+
+ @Test
+ public void test2wayAddNewStringTypedEReference() throws IOException {
+ final Resource leftResource = inputData.getLeft();
+ final Resource rightResource = inputData.getRight();
+ final IComparisonScope scope = new DefaultComparisonScope(leftResource, rightResource, null);
+ final Builder comparisonBuilder = EMFCompare.builder();
+ EMFCompareBuilderConfigurator.createDefault().configure(comparisonBuilder);
+ final Comparison comparison = comparisonBuilder.build().compare(scope);
+
+ new MatchOfContainmentReferenceChangeProcessor().execute(comparison);
+
+ for (Match match : comparison.getMatches()) {
+ Adapter adapter = EcoreUtil.getAdapter(match.eAdapters(),
+ MatchOfContainmentReferenceChangeAdapter.class);
+ assertNull(adapter);
+ for (Match subMatch : match.getAllSubmatches()) {
+ adapter = EcoreUtil.getAdapter(subMatch.eAdapters(),
+ MatchOfContainmentReferenceChangeAdapter.class);
+ // The only match with a MatchOfContainmentReferenceChangeAdapter is the match on title
+ EObject left = subMatch.getLeft();
+ if (left instanceof EStructuralFeature
+ && ((EStructuralFeature)left).getName().equals("title")) {
+ assertNotNull(adapter);
+ } else {
+ assertNull(adapter);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/MatchOfContainmentReferenceChangeAdapterTestData.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/MatchOfContainmentReferenceChangeAdapterTestData.java
new file mode 100644
index 000000000..36d89d966
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/MatchOfContainmentReferenceChangeAdapterTestData.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.rcp.ui.tests.structuremergeviewer.match.data;
+
+import java.io.IOException;
+
+import org.eclipse.emf.compare.tests.edit.data.ResourceScopeProvider;
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+
+public class MatchOfContainmentReferenceChangeAdapterTestData extends AbstractInputData implements ResourceScopeProvider {
+
+ public Resource getLeft() throws IOException {
+ return loadFromClassLoader("left.ecore");
+ }
+
+ public Resource getRight() throws IOException {
+ return loadFromClassLoader("right.ecore");
+ }
+
+ public Resource getOrigin() throws IOException {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/left.ecore b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/left.ecore
new file mode 100644
index 000000000..f106458be
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/left.ecore
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_14sTEG60EeGkd4g88tZXfA" name="extlibrary" nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0"
+ nsPrefix="extlib">
+ <eClassifiers xsi:type="ecore:EClass" xmi:id="_146VgG60EeGkd4g88tZXfA" name="Book">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_146VgW60EeGkd4g88tZXfA"
+ name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/right.ecore b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/right.ecore
new file mode 100644
index 000000000..82573635c
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/match/data/right.ecore
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmi:id="_14sTEG60EeGkd4g88tZXfA" name="extlibrary" nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0"
+ nsPrefix="extlib">
+ <eClassifiers xsi:type="ecore:EClass" xmi:id="_146VgG60EeGkd4g88tZXfA" name="Book"/>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java
index 00b5af1a6..65a6da209 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/suite/AllTests.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.groups.provider
import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.groups.provider.TestMatchTreeNodeItemProviderSpec;
import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.groups.provider.TestReferenceChangeTreeNodeItemProviderSpec;
import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.groups.provider.ThreeWayComparisonGroupProviderTest;
+import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.match.MatchOfContainmentReferenceChangeAdapterTest;
import org.eclipse.emf.compare.tests.nodes.NodesPackage;
import org.eclipse.emf.compare.tests.nodes.util.NodesResourceFactoryImpl;
import org.eclipse.emf.ecore.EPackage;
@@ -45,7 +46,8 @@ import junit.textui.TestRunner;
MergeViewerItemPseudoConflictTest.class, MergeViewerItemFeatureMapsTest.class,
TestBasicDifferenceGroupImpl.class, BugsTestSuite.class, TestFeatureMapDifferencesFilter.class,
RCPMatchEngineFactoryRegistryTest.class, ThreeWayComparisonGroupProviderTest.class,
- ConflictsGroupTest.class, MatchAccessorTest.class, TechnicalitiesFilterTests.class, })
+ ConflictsGroupTest.class, MatchAccessorTest.class, TechnicalitiesFilterTests.class,
+ MatchOfContainmentReferenceChangeAdapterTest.class })
public class AllTests {
/**
* Launches the test with the given arguments.
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF
index 432829606..7bb595a2e 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/META-INF/MANIFEST.MF
@@ -46,6 +46,7 @@ Export-Package: org.eclipse.emf.compare.rcp.ui,
org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.extender;x-friends:="org.eclipse.emf.compare.ide.ui",
org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests",
org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider;x-friends:="org.eclipse.emf.compare.ide.ui,org.eclipse.emf.compare.diagram.papyrus.tests,org.eclipse.emf.compare.uml2.rcp.ui.tests",
+ org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.match,
org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.nodes,
org.eclipse.emf.compare.rcp.ui.internal.util;x-friends:="org.eclipse.emf.compare.ide.ui",
org.eclipse.emf.compare.rcp.ui.mergeviewer,
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/filters/impl/CascadingDifferencesFilter.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/filters/impl/CascadingDifferencesFilter.java
index aa2fb2562..ce211081a 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/filters/impl/CascadingDifferencesFilter.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/filters/impl/CascadingDifferencesFilter.java
@@ -16,8 +16,6 @@ import static org.eclipse.emf.compare.ConflictKind.REAL;
import static org.eclipse.emf.compare.DifferenceKind.ADD;
import static org.eclipse.emf.compare.DifferenceKind.DELETE;
import static org.eclipse.emf.compare.DifferenceKind.MOVE;
-import static org.eclipse.emf.compare.DifferenceSource.LEFT;
-import static org.eclipse.emf.compare.DifferenceSource.RIGHT;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.CONTAINMENT_REFERENCE_CHANGE;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.fromSide;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.hasNoDirectOrIndirectConflict;
@@ -28,13 +26,16 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.UnmodifiableIterator;
+import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ResourceAttachmentChange;
+import org.eclipse.emf.compare.match.MatchOfContainmentReferenceChangeAdapter;
import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.filters.AbstractDifferenceFilter;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.tree.TreeNode;
/**
@@ -135,22 +136,9 @@ public class CascadingDifferencesFilter extends AbstractDifferenceFilter {
if (match == null) {
return false;
}
- if (match.getComparison().isThreeWay()) {
- return (MatchUtil.getMatchedObject(match, side) == null) != (match.getOrigin() == null);
- }
- return (MatchUtil.getMatchedObject(match, side) == null) != (MatchUtil.getMatchedObject(match,
- opposite(side)) == null);
- }
-
- protected DifferenceSource opposite(DifferenceSource side) {
- switch (side) {
- case LEFT:
- return RIGHT;
- case RIGHT:
- return LEFT;
- default:
- throw new IllegalArgumentException("Source value not supported: " + side); //$NON-NLS-1$
- }
+ Adapter adapter = EcoreUtil.getAdapter(match.eAdapters(),
+ MatchOfContainmentReferenceChangeAdapter.class);
+ return adapter != null;
}
};
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java
new file mode 100644
index 000000000..38a9fefc9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.rcp.ui.internal.structuremergeviewer.match;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.compare.match.MatchOfContainmentReferenceChangeAdapter;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Process a comparison to detect {@link Match}es related to containment ReferenceChange. Add a
+ * {@link MatchOfContainmentReferenceChangeAdapter} on such Matches.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+public class MatchOfContainmentReferenceChangeProcessor {
+
+ /**
+ * Constructor.
+ */
+ public MatchOfContainmentReferenceChangeProcessor() {
+ }
+
+ /**
+ * Check for the given {@link Comparison}, if {@link Match}es are related to a containment
+ * ReferenceChange. If it is add a {@link MatchOfContainmentReferenceChangeAdapter} to these
+ * {@link Match}es.
+ *
+ * @param comp
+ * The {@link Comparison} to check.
+ */
+ public void execute(Comparison comp) {
+ for (Match rootMatch : comp.getMatches()) {
+ checkForMatchRelatedToContainmentReferenceChange(rootMatch);
+ }
+ }
+
+ /**
+ * Check if the given {@link Match} is related to a containment ReferenceChange. If it is add a
+ * {@link MatchOfContainmentReferenceChangeAdapter} to this {@link Match}. Also check for all sub-matches
+ * of the given {@link Match}.
+ *
+ * @param match
+ * The {@link Match} to check
+ */
+ protected void checkForMatchRelatedToContainmentReferenceChange(Match match) {
+ EObject parentMatch = match.eContainer();
+ if (parentMatch instanceof Match) {
+ EList<Diff> differences = ((Match)parentMatch).getDifferences();
+ for (Diff parentMatchDiff : differences) {
+ if (EMFComparePredicates.CONTAINMENT_REFERENCE_CHANGE.apply(parentMatchDiff)) {
+ EObject value = ((ReferenceChange)parentMatchDiff).getValue();
+ if (value != null && (value.equals(match.getLeft()) || value.equals(match.getRight())
+ || value.equals(match.getOrigin()))) {
+ match.eAdapters().add(new MatchOfContainmentReferenceChangeAdapter(
+ (ReferenceChange)parentMatchDiff));
+ break;
+ }
+ }
+ }
+ }
+ for (Match subMatch : match.getSubmatches()) {
+ checkForMatchRelatedToContainmentReferenceChange(subMatch);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/MatchOfContainmentReferenceChangeAdapter.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/MatchOfContainmentReferenceChangeAdapter.java
new file mode 100644
index 000000000..b1a923c63
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/MatchOfContainmentReferenceChangeAdapter.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.match;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ReferenceChange;
+
+/**
+ * Specific {@link Adapter} to {@link Match}es that are related to containment {@link ReferenceChange}s (that
+ * are placed in their parent {@link Match}).
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+public class MatchOfContainmentReferenceChangeAdapter extends AdapterImpl {
+
+ /** The {@link ReferenceChange} to associate with the adapted {@link Match}. */
+ private ReferenceChange referenceChange;
+
+ /**
+ * Constructor.
+ *
+ * @param referenceChange
+ * The {@link ReferenceChange} to associate with the adapted {@link Match}.
+ */
+ public MatchOfContainmentReferenceChangeAdapter(ReferenceChange referenceChange) {
+ super();
+ this.referenceChange = referenceChange;
+ }
+
+ /**
+ * {@inheritDoc} .
+ *
+ * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(Object)
+ */
+ @Override
+ public boolean isAdapterForType(Object type) {
+ if (type == MatchOfContainmentReferenceChangeAdapter.class) {
+ return true;
+ }
+ return super.isAdapterForType(type);
+ }
+
+ /**
+ * Get the {@link ReferenceChange} to associate with the adapted {@link Match}.
+ *
+ * @return The {@link ReferenceChange} to associate with the adapted {@link Match}.
+ */
+ public ReferenceChange getReferenceChange() {
+ return referenceChange;
+ }
+}

Back to the top