diff options
author | lgoubet | 2019-04-18 07:22:55 +0000 |
---|---|---|
committer | lgoubet | 2019-04-18 07:22:55 +0000 |
commit | 382d98c7ea5028fd3e8c24eb607ee2526de93016 (patch) | |
tree | c5bd3d1482af5759298707b8a3aa2aaabd2d2502 /plugins | |
parent | f70feb71f1db3f98de2200c4ea6adefbf622588b (diff) | |
download | org.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
Change-Id: Ie5d4c3d0d9f807aad3d8c404cb17d41140cbdded
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.java | 22 |
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)); + } } } } |