Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-04-18 07:22:55 +0000
committerlgoubet2019-04-18 07:22:55 +0000
commit382d98c7ea5028fd3e8c24eb607ee2526de93016 (patch)
treec5bd3d1482af5759298707b8a3aa2aaabd2d2502 /plugins
parentf70feb71f1db3f98de2200c4ea6adefbf622588b (diff)
downloadorg.eclipse.emf.compare-382d98c7ea5028fd3e8c24eb607ee2526de93016.tar.gz
org.eclipse.emf.compare-382d98c7ea5028fd3e8c24eb607ee2526de93016.tar.xz
org.eclipse.emf.compare-382d98c7ea5028fd3e8c24eb607ee2526de93016.zip
Only add new adapters when needed
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/structuremergeviewer/match/MatchOfContainmentReferenceChangeProcessor.java22
1 files changed, 14 insertions, 8 deletions
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
index c19042627..aa10b10ee 100644
--- 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
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.match;
+import java.util.Iterator;
+
+import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.Match;
@@ -24,13 +27,6 @@ import org.eclipse.emf.compare.utils.EMFComparePredicates;
* @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
@@ -43,7 +39,17 @@ public class MatchOfContainmentReferenceChangeProcessor {
for (Diff diff : comp.getDifferences()) {
if (EMFComparePredicates.CONTAINMENT_REFERENCE_CHANGE.apply(diff)) {
Match match = comp.getMatch(((ReferenceChange)diff).getValue());
- match.eAdapters().add(new MatchOfContainmentReferenceChangeAdapter((ReferenceChange)diff));
+ boolean hasAdapter = false;
+ Iterator<Adapter> adapters = match.eAdapters().iterator();
+ while (!hasAdapter && adapters.hasNext()) {
+ Adapter next = adapters.next();
+ hasAdapter = next instanceof MatchOfContainmentReferenceChangeAdapter
+ && ((MatchOfContainmentReferenceChangeAdapter)next).getReferenceChange() == diff;
+ }
+ if (!hasAdapter) {
+ match.eAdapters()
+ .add(new MatchOfContainmentReferenceChangeAdapter((ReferenceChange)diff));
+ }
}
}
}

Back to the top