Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2015-06-22 07:53:37 +0000
committerAxel RICHARD2015-07-10 07:55:16 +0000
commitfb6341cdb3a9953bec48193be54c16dcb19c76dd (patch)
tree7a372cd2384e545a12825d8bfd8b5a8599f17fe7 /plugins
parentd9d1e37aa60c19d79970a7b6bb4b1380e430be07 (diff)
downloadorg.eclipse.emf.compare-fb6341cdb3a9953bec48193be54c16dcb19c76dd.tar.gz
org.eclipse.emf.compare-fb6341cdb3a9953bec48193be54c16dcb19c76dd.tar.xz
org.eclipse.emf.compare-fb6341cdb3a9953bec48193be54c16dcb19c76dd.zip
[470503] Some cascading diffs not merged with menu/merge actions
Cascading diff was not taking into account with the contextual menu. It was also not taking into account by the merge right to left / left to right actions. Add new test case. Change-Id: I1cd7bf15359c875ded35585e56d253d7db2f4617 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/TestBug470503.java190
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/left.ecore9
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/right.ecore15
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java27
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java13
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java16
7 files changed, 272 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/TestBug470503.java b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/TestBug470503.java
new file mode 100644
index 000000000..7b48eb4f6
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/TestBug470503.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.tests.structuremergeviewer.actions;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.eclipse.emf.compare.Comparison;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceState;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.Match;
+import org.eclipse.emf.compare.ReferenceChange;
+import org.eclipse.emf.compare.domain.ICompareEditingDomain;
+import org.eclipse.emf.compare.domain.impl.EMFCompareEditingDomain;
+import org.eclipse.emf.compare.internal.merge.MergeMode;
+import org.eclipse.emf.compare.internal.merge.MergeOperation;
+import org.eclipse.emf.compare.merge.IMerger;
+import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
+import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.DefaultGroupProvider;
+import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeNodeItemProviderSpec;
+import org.eclipse.emf.compare.rcp.ui.tests.structuremergeviewer.groups.provider.AbstractTestTreeNodeItemProviderAdapter;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.tree.TreeFactory;
+import org.eclipse.emf.edit.tree.TreeNode;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This test is related to the bug <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=470503">470503</a>
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+@SuppressWarnings({"nls", "restriction" })
+public class TestBug470503 extends AbstractTestTreeNodeItemProviderAdapter {
+
+ private static TreeNodeItemProviderSpec itemProvider;
+
+ private IMerger.Registry mergerRegistry;
+
+ private ICompareEditingDomain editingDomain;
+
+ private TreeNode titledItemESuperTypesDelete;
+
+ private TreeNode titledItemEClassifiersDelete;
+
+ private TreeNode titleESFDelete;
+
+ @Override
+ @Before
+ public void before() throws IOException {
+ super.before();
+ itemProvider = (TreeNodeItemProviderSpec)treeItemProviderAdapterFactory.createTreeNodeAdapter();
+ mergerRegistry = EMFCompareRCPPlugin.getDefault().getMergerRegistry();
+
+ Bug470503InputData inputData = new Bug470503InputData();
+ final Resource left = inputData.getResource("left.ecore"); //$NON-NLS-1$
+ final Resource right = inputData.getResource("right.ecore"); //$NON-NLS-1$
+ final DefaultComparisonScope scope = new DefaultComparisonScope(left, right, null);
+ final Comparison comparison = EMFCompare.builder().build().compare(scope);
+
+ editingDomain = EMFCompareEditingDomain.create(left, right, null);
+
+ TreeNode ePackageMatch = getExtlibrary_EPackageMatch(comparison);
+ Collection<?> ePackage_MatchChildren = ePackageMatch.getChildren();
+ Iterable<EObject> ePackage_MatchChildrenData = transform(ePackage_MatchChildren, TREE_NODE_DATA);
+
+ // Get children of Match Book
+ Match book_Match = getMatchWithFeatureValue(ePackage_MatchChildrenData, "name", "Book");
+ TreeNode book_Match_Node = getTreeNode(ePackageMatch, book_Match);
+ Collection<?> book_MatchChildren = book_Match_Node.getChildren();
+ Iterable<EObject> book_MatchChildrenData = transform(book_MatchChildren, TREE_NODE_DATA);
+
+ // Get TitledItem [eSuperTypes delete] difference
+ ReferenceChange titledItemESuperTypesDeleteChange = getReferenceChangeWithFeatureValue(
+ book_MatchChildrenData, "name", "TitledItem");
+ titledItemESuperTypesDelete = getTreeNode(book_Match_Node, titledItemESuperTypesDeleteChange);
+
+ // Get TitledItem [eClassifiers delete] difference
+ ReferenceChange titledItemEClassifiersDeleteChange = getReferenceChangeWithFeatureValue(
+ ePackage_MatchChildrenData, "name", "TitledItem");
+ titledItemEClassifiersDelete = getTreeNode(ePackageMatch, titledItemEClassifiersDeleteChange);
+
+ // Get children of Match TitledItem
+ TreeNode titledItem_Match_Node = getTreeNode(ePackageMatch, titledItemEClassifiersDeleteChange);
+ Collection<?> titledItem_MatchChildren = titledItem_Match_Node.getChildren();
+ Iterable<EObject> titledItem_MatchChildrenData = transform(titledItem_MatchChildren, TREE_NODE_DATA);
+
+ // Get title [eStructuralFeatures delete] difference
+ ReferenceChange titleESFDeleteChange = getReferenceChangeWithFeatureValue(
+ titledItem_MatchChildrenData, "name", "title");
+ titleESFDelete = getTreeNode(titledItem_Match_Node, titleESFDeleteChange);
+ }
+
+ @Test
+ public void testMergeWithCascadingFilter() {
+ final MergeMode rightToLeft = MergeMode.RIGHT_TO_LEFT;
+ final boolean leftEditable = true;
+ final boolean rightEditable = true;
+ final boolean cascadingFilter = true;
+ MockMergeAction action = new MockMergeAction(editingDomain, mergerRegistry, rightToLeft,
+ leftEditable, rightEditable, null);
+
+ // Merge from right to left TitledItem [eSuperTypes delete] difference difference
+ Diff titledItemESuperTypesDeleteDiff = (Diff)titledItemESuperTypesDelete.getData();
+ assertFalse(rightToLeft.isLeftToRight(titledItemESuperTypesDeleteDiff, leftEditable, rightEditable));
+ assertEquals(MergeOperation.MERGE, rightToLeft.getMergeAction(titledItemESuperTypesDeleteDiff,
+ leftEditable, rightEditable));
+ action.updateSelection(new StructuredSelection(titledItemESuperTypesDelete));
+ action.setCascadingDifferencesFilterEnabled(cascadingFilter);
+ action.run();
+ assertEquals(DifferenceState.MERGED, titledItemESuperTypesDeleteDiff.getState());
+
+ Diff titledItemEClassifiersDeleteDiff = (Diff)titledItemEClassifiersDelete.getData();
+ assertEquals(DifferenceState.MERGED, titledItemEClassifiersDeleteDiff.getState());
+
+ Diff titleESFDeleteDiff = (Diff)titleESFDelete.getData();
+ assertEquals(DifferenceState.MERGED, titleESFDeleteDiff.getState());
+ }
+
+ @Test
+ public void testMergeWithoutCascadingFilter() {
+ final MergeMode rightToLeft = MergeMode.RIGHT_TO_LEFT;
+ final boolean leftEditable = true;
+ final boolean rightEditable = true;
+ final boolean cascadingFilter = false;
+ MockMergeAction action = new MockMergeAction(editingDomain, mergerRegistry, rightToLeft,
+ leftEditable, rightEditable, null);
+
+ // Merge from right to left TitledItem [eSuperTypes delete] difference difference
+ Diff titledItemESuperTypesDeleteDiff = (Diff)titledItemESuperTypesDelete.getData();
+ assertFalse(rightToLeft.isLeftToRight(titledItemESuperTypesDeleteDiff, leftEditable, rightEditable));
+ assertEquals(MergeOperation.MERGE, rightToLeft.getMergeAction(titledItemESuperTypesDeleteDiff,
+ leftEditable, rightEditable));
+ action.updateSelection(new StructuredSelection(titledItemESuperTypesDelete));
+ action.setCascadingDifferencesFilterEnabled(cascadingFilter);
+ action.run();
+ assertEquals(DifferenceState.MERGED, titledItemESuperTypesDeleteDiff.getState());
+
+ Diff titledItemEClassifiersDeleteDiff = (Diff)titledItemEClassifiersDelete.getData();
+ assertEquals(DifferenceState.MERGED, titledItemEClassifiersDeleteDiff.getState());
+
+ Diff titleESFDeleteDiff = (Diff)titleESFDelete.getData();
+ assertEquals(DifferenceState.UNRESOLVED, titleESFDeleteDiff.getState());
+ }
+
+ private static TreeNode getExtlibrary_EPackageMatch(Comparison comparison) throws IOException {
+ TreeNode treeNode = TreeFactory.eINSTANCE.createTreeNode();
+ treeNode.setData(comparison);
+ treeNode.eAdapters().add(new DefaultGroupProvider());
+
+ Collection<?> children = itemProvider.getChildren(treeNode);
+
+ Iterable<?> matches = filter(children, matchTreeNode);
+ return (TreeNode)matches.iterator().next();
+ }
+
+ /**
+ * Input data for this bug.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+ public class Bug470503InputData extends AbstractInputData {
+
+ private static final String PATH_PREFIX = "data/_470503/"; //$NON-NLS-1$
+
+ public Resource getResource(String resourceName) throws IOException {
+ StringBuilder resourceURL = new StringBuilder(PATH_PREFIX);
+ resourceURL.append(resourceName);
+ return loadFromClassLoader(resourceURL.toString());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/left.ecore b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/left.ecore
new file mode 100644
index 000000000..c50578f62
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/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.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/right.ecore b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/right.ecore
new file mode 100644
index 000000000..ea72c9b55
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/data/_470503/right.ecore
@@ -0,0 +1,15 @@
+<?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"
+ eSuperTypes="#_9M9ys29IEeGekPcBm25hwQ">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_146Vg260EeGkd4g88tZXfA"
+ name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
+ defaultValueLiteral="100"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" xmi:id="_9M9ys29IEeGekPcBm25hwQ" name="TitledItem">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" xmi:id="_9M9ytG9IEeGekPcBm25hwQ"
+ name="title"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java
index 92ea6303a..22340e9c8 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug
import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug434827;
import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug434828;
import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug434828_2;
+import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug470503;
import org.eclipse.emf.compare.ide.ui.tests.unit.TestBug459131;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -33,7 +34,8 @@ import org.junit.runners.Suite.SuiteClasses;
TestBug434822.class,
TestBug434828.class,
TestBug434828_2.class,
- TestBug459131.class})
+ TestBug459131.class,
+ TestBug470503.class})
public class BugsTestSuite {
/**
* Launches the test with the given arguments.
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 c3eee9e16..69c4ab155 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
@@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer;
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Iterables.size;
import static org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.CallbackType.IN_UI_ASYNC;
import static org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.CallbackType.IN_UI_SYNC;
@@ -113,6 +115,7 @@ import org.eclipse.emf.compare.rcp.ui.internal.configuration.IMergePreviewModeCh
import org.eclipse.emf.compare.rcp.ui.internal.configuration.SideLabelProvider;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.IColorChangeEvent;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.StructureMergeViewerFilter;
+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.util.SWTUtil;
@@ -261,6 +264,8 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
private FetchListener toolbarUpdaterContentProviderListener;
+ private boolean cascadingDifferencesFilterEnabled;
+
/**
* Constructor.
*
@@ -660,6 +665,9 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
@Subscribe
public void handleDifferenceFilterChange(IDifferenceFilterChange event) {
+ final boolean enabled = any(event.getSelectedDifferenceFilters(),
+ instanceOf(CascadingDifferencesFilter.class));
+ setCascadingDifferencesFilterEnabled(enabled);
SWTUtil.safeRefresh(this, false, true);
getContentProvider().runWhenReady(IN_UI_ASYNC, new Runnable() {
public void run() {
@@ -672,6 +680,25 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
});
}
+ /**
+ * Set the state of the cascading filter.
+ *
+ * @param enable
+ * true if the filter is enabled, false otherwise.
+ */
+ private void setCascadingDifferencesFilterEnabled(boolean enable) {
+ this.cascadingDifferencesFilterEnabled = enable;
+ }
+
+ /**
+ * Get the state of the cascading filter.
+ *
+ * @return true if the filter is enabled, false otherwise.
+ */
+ private boolean getCascadingDifferencesFilterEnabled() {
+ return this.cascadingDifferencesFilterEnabled;
+ }
+
@Subscribe
public void handleDifferenceGroupProviderChange(
@SuppressWarnings("unused") IDifferenceGroupProviderChange event) {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java
index cdeed7e89..58f4b7cc3 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java
@@ -18,8 +18,10 @@ import static com.google.common.collect.Lists.newArrayList;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
import java.util.List;
+import java.util.Set;
import org.eclipse.compare.INavigatable;
import org.eclipse.emf.common.notify.Adapter;
@@ -34,6 +36,7 @@ import org.eclipse.emf.compare.internal.merge.MergeMode;
import org.eclipse.emf.compare.internal.utils.ComparisonUtil;
import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.merge.IMerger.Registry;
+import org.eclipse.emf.compare.merge.IMerger2;
import org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroup;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.tree.TreeNode;
@@ -167,7 +170,15 @@ public class MergeAction extends BaseSelectionListenerAction {
List<Diff> differencesToMerge = newArrayList(selectedDifferences);
if (cascadingDifferencesFilterEnabled) {
- Iterable<Diff> cascadingDifferences = concat(transform(selectedDifferences, ComparisonUtil
+ Set<Diff> setToMerge = Sets.newHashSet(differencesToMerge);
+ for (Diff difftoMerge : differencesToMerge) {
+ IMerger merger = mergerRegistry.getHighestRankingMerger(difftoMerge);
+ if (merger instanceof IMerger2) {
+ addAll(setToMerge, ((IMerger2)merger).getDirectMergeDependencies(difftoMerge,
+ !leftToRight));
+ }
+ }
+ Iterable<Diff> cascadingDifferences = concat(transform(setToMerge, ComparisonUtil
.getSubDiffs(leftToRight)));
addAll(differencesToMerge, cascadingDifferences);
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
index 029930597..224bd8f1a 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.util.Iterator;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.AttributeChange;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.Match;
@@ -132,6 +133,21 @@ public class AbstractTestTreeNodeItemProviderAdapter {
return find(matches, predicate);
}
+ protected AttributeChange getAttributeChangeWithFeatureValue(Iterable<?> c, final String featureName,
+ final Object value) {
+ Iterable<AttributeChange> matches = filter(c, AttributeChange.class);
+ Predicate<AttributeChange> predicate = new Predicate<AttributeChange>() {
+ public boolean apply(AttributeChange attributeChange) {
+ Object attributeChangeValue = attributeChange.getValue();
+ if (attributeChangeValue instanceof EObject) {
+ return Objects.equal(eGet((EObject) attributeChangeValue, featureName), value);
+ }
+ return false;
+ }
+ };
+ return find(matches, predicate);
+ }
+
protected Predicate<Match> hasFeatureValue(final String featureName, final Object value) {
Predicate<Match> predicate = new Predicate<Match>() {
public boolean apply(Match match) {

Back to the top