Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-07-20 09:56:31 +0000
committervlorenzo2012-07-20 09:56:31 +0000
commit8f60a841b4db7d0237120cc79aada4e294f8ff18 (patch)
tree4316305e8713172004a2bba9ca702933447d7088 /extraplugins
parent2a3f1015dd80424367efdc09a5a7a98c210eac27 (diff)
downloadorg.eclipse.papyrus-8f60a841b4db7d0237120cc79aada4e294f8ff18.tar.gz
org.eclipse.papyrus-8f60a841b4db7d0237120cc79aada4e294f8ff18.tar.xz
org.eclipse.papyrus-8f60a841b4db7d0237120cc79aada4e294f8ff18.zip
385579: [UML Compare] NPE : EditingDomain not found for comparison between an element located in a Resource and another one not located in a Resource
https://bugs.eclipse.org/bugs/show_bug.cgi?id=385579
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java
index 43d08c1049e..a15e771081a 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java
@@ -66,12 +66,12 @@ import org.eclipse.papyrus.infra.emf.compare.diff.service.TransactionalMergeServ
* should replace DefaultMerger
*
*/
-//TODO can we remoe IMerger?
+//TODO can we remove IMerger?
public class DefaultTransactionalMerger extends AbstractDefaultMerger implements ITransactionalMerger {
//---------------------These methods comes from ITransactionalMerger
public Command getApplyInOriginCommand(TransactionalEditingDomain domain) {
- CompoundCommand cmd = new CompoundCommand(NLS.bind("Apply in Origin Command for {0}", this.diff));
+ CompoundCommand cmd = new CompoundCommand(NLS.bind("Apply in Origin Command for {0}", this.diff)); //$NON-NLS-1$
cmd.append(getMergeRequiredDifferencesCommand(domain, true));
cmd.append(getDoApplyInOriginCommand(domain));
cmd.append(getPostProcessCommand(domain));
@@ -79,7 +79,7 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
}
public Command getUndoInTargetCommand(TransactionalEditingDomain domain) {
- CompoundCommand cmd = new CompoundCommand(NLS.bind("Undo in Target Command for {0}", this.diff));
+ CompoundCommand cmd = new CompoundCommand(NLS.bind("Undo in Target Command for {0}", this.diff)); //$NON-NLS-1$
cmd.append(getMergeRequiredDifferencesCommand(domain, false));
cmd.append(getDoUndoInTargetCommand(domain));
cmd.append(getPostProcessCommand(domain));
@@ -95,7 +95,7 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
}
public Command getMergeRequiredDifferencesCommand(TransactionalEditingDomain domain, boolean applyInOrigin) {
- CompoundCommand cmd = new CompoundCommand("Merge required differences");
+ CompoundCommand cmd = new CompoundCommand("Merge required differences"); //$NON-NLS-1$
// if(mergedDiffs == null) { //we need to clean it, to avoid that the command creation duplicate elements in this list
mergedDiffs = new ArrayList<DiffElement>();
if(mergedDiffslistener == null) {
@@ -150,12 +150,24 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
break;
}
}
- EObject element = (EObject)ClassUtils.invokeMethod(diffElement, "getRightElement");
+ //we try to get the EditingDomain using the left object AND the rightObject,
+ //because in some case it should be interesting to do a comparison between an object contained by a resource
+ //and an other object no contained by a resource
+ EObject element = (EObject)ClassUtils.invokeMethod(diffElement, "getRightElement"); //$NON-NLS-1$
if(element == null) {
- element = (EObject)ClassUtils.invokeMethod(diffElement, "getLeftElement");
+ element = (EObject)ClassUtils.invokeMethod(diffElement, "getLeftElement"); //$NON-NLS-1$
}
- final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(element);
- Assert.isNotNull(domain, NLS.bind("I didn't found the EditingDomain for {0}", diff));
+ TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(element);
+
+ if(domain == null) {
+ element = (EObject)ClassUtils.invokeMethod(diffElement, "getRightParent"); //$NON-NLS-1$
+ if(element == null) {
+ element = (EObject)ClassUtils.invokeMethod(diffElement, "getLeftParent"); //$NON-NLS-1$
+ }
+ domain = TransactionUtil.getEditingDomain(element);
+ }
+
+ Assert.isNotNull(domain, NLS.bind("I didn't found the EditingDomain for {0}", diff)); //$NON-NLS-1$
return domain;
}

Back to the top