Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-04-25 16:07:18 +0000
committerMikaël Barbero2013-04-25 16:07:18 +0000
commita22e6ab94728137a1130f572d15468f6545ff755 (patch)
treed62fd92d2706f5262d439b5a3958ab6f300d041a
parentd7835d8fb2398c83ca198ce073c29c36380c6c29 (diff)
downloadorg.eclipse.emf.compare-a22e6ab94728137a1130f572d15468f6545ff755.tar.gz
org.eclipse.emf.compare-a22e6ab94728137a1130f572d15468f6545ff755.tar.xz
org.eclipse.emf.compare-a22e6ab94728137a1130f572d15468f6545ff755.zip
[406541] allow merge when comparing two EObjects
Do not systematically create TransactionalEditingDomain in constructor
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/domain/impl/EMFCompareEditingDomain.java44
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java6
2 files changed, 28 insertions, 22 deletions
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/domain/impl/EMFCompareEditingDomain.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/domain/impl/EMFCompareEditingDomain.java
index 8a155391f..5ed82f129 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/domain/impl/EMFCompareEditingDomain.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/domain/impl/EMFCompareEditingDomain.java
@@ -53,31 +53,13 @@ public class EMFCompareEditingDomain implements ICompareEditingDomain {
fNotifiers = ImmutableList.of(left, right, ancestor);
}
- final ResourceSet leftRS = getResourceSet(left);
- final ResourceSet rightRS = getResourceSet(right);
-
- if (leftRS != null && rightRS != null) {
- TransactionalEditingDomain leftTED = TransactionalEditingDomain.Factory.INSTANCE
- .getEditingDomain(leftRS);
- TransactionalEditingDomain rightTED = TransactionalEditingDomain.Factory.INSTANCE
- .getEditingDomain(rightRS);
- if (leftTED == null) {
- leftTED = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(leftRS);
- }
- if (rightTED == null) {
- rightTED = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(rightRS);
- }
- fCommandStack = new DualCompareCommandStack((BasicCommandStack)leftTED.getCommandStack(),
- (BasicCommandStack)rightTED.getCommandStack());
- } else {
- fCommandStack = commandStack;
- }
+ fCommandStack = commandStack;
fChangeRecorder = new ChangeRecorder();
fChangeRecorder.setResolveProxies(false);
}
- public ResourceSet getResourceSet(Notifier notifier) {
+ private static ResourceSet getResourceSet(Notifier notifier) {
ResourceSet resourceSet = null;
if (notifier instanceof ResourceSet) {
resourceSet = (ResourceSet)notifier;
@@ -95,7 +77,27 @@ public class EMFCompareEditingDomain implements ICompareEditingDomain {
}
public static ICompareEditingDomain create(Notifier left, Notifier right, Notifier ancestor) {
- return create(left, right, ancestor, new BasicCommandStack());
+ final ResourceSet leftRS = getResourceSet(left);
+ final ResourceSet rightRS = getResourceSet(right);
+
+ final CommandStack commandStack;
+ if (leftRS != null && rightRS != null) {
+ TransactionalEditingDomain leftTED = TransactionalEditingDomain.Factory.INSTANCE
+ .getEditingDomain(leftRS);
+ TransactionalEditingDomain rightTED = TransactionalEditingDomain.Factory.INSTANCE
+ .getEditingDomain(rightRS);
+ if (leftTED == null) {
+ leftTED = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(leftRS);
+ }
+ if (rightTED == null) {
+ rightTED = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(rightRS);
+ }
+ commandStack = new DualCompareCommandStack((BasicCommandStack)leftTED.getCommandStack(),
+ (BasicCommandStack)rightTED.getCommandStack());
+ } else {
+ commandStack = new BasicCommandStack();
+ }
+ return create(left, right, ancestor, commandStack);
}
public static ICompareEditingDomain create(Notifier left, Notifier right, Notifier ancestor,
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java
index ec4e0f3a9..877712a05 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/handler/AbstractCompareHandler.java
@@ -97,7 +97,11 @@ public abstract class AbstractCompareHandler extends AbstractHandler {
delegatingCommandStack = delegatingEditingDomain.getCommandStack();
}
- return EMFCompareEditingDomain.create(left, right, origin, delegatingCommandStack);
+ if (delegatingCommandStack == null) {
+ return EMFCompareEditingDomain.create(left, right, origin);
+ } else {
+ return EMFCompareEditingDomain.create(left, right, origin, delegatingCommandStack);
+ }
}
private static EditingDomain getDelegatingEditingDomain(final IWorkbenchPart activePart, Notifier left,

Back to the top