Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-04-12 05:39:50 -0400
committervlorenzo2012-04-12 05:39:50 -0400
commitbf98fc3a34ba475e34c4453c53ffac6d9f16f940 (patch)
treefce6f785fc3c38a8286f8e7dcac403bbb155de58 /sandbox/UMLCompareMergerExample
parent9b331bdb7e09bb65e9fcddccc7c479f2803a9cc7 (diff)
downloadorg.eclipse.papyrus-bf98fc3a34ba475e34c4453c53ffac6d9f16f940.tar.gz
org.eclipse.papyrus-bf98fc3a34ba475e34c4453c53ffac6d9f16f940.tar.xz
org.eclipse.papyrus-bf98fc3a34ba475e34c4453c53ffac6d9f16f940.zip
342163: [Usability] Papyrus merge should use the service edit of Papyrus
https://bugs.eclipse.org/bugs/show_bug.cgi?id=342163
Diffstat (limited to 'sandbox/UMLCompareMergerExample')
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF3
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java55
2 files changed, 55 insertions, 3 deletions
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF
index 914a7a23080..bd735de3519 100644
--- a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.services.edit,
org.eclipse.emf.compare,
org.eclipse.papyrus.infra.tools;bundle-version="0.9.0",
- org.eclipse.papyrus.infra.core.sasheditor
+ org.eclipse.papyrus.infra.core.sasheditor,
+ com.google.guava
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java
index f440859e7e1..b077a0872b0 100644
--- a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java
@@ -1,14 +1,48 @@
package org.eclipse.papyrus.uml.merger.provider;
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.EMFComparePlugin;
+import org.eclipse.emf.compare.FactoryException;
import org.eclipse.emf.compare.diff.internal.merge.impl.ReferenceOrderChangeMerger;
+import org.eclipse.emf.compare.diff.merge.DefaultMerger;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.compare.util.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
public class CReferenceOrderChangeMerger extends ReferenceOrderChangeMerger {
+
@Override
public void doUndoInTarget() {
if(MergerUtils.usePapyrusMerger()) {
- throw new UnsupportedOperationException();
+ final ReferenceOrderChange theDiff = (ReferenceOrderChange)this.diff;
+ final EObject rightElement = theDiff.getRightElement();
+
+ final Collection<EObject> target = Lists.newArrayList(Collections2.filter(theDiff.getRightTarget(),
+ new Predicate<EObject>() {
+ public boolean apply(EObject input) {
+ return !input.eIsProxy()
+ || !DefaultMerger.isEMFCompareProxy(((InternalEObject)input).eProxyURI());
+ }
+ }));
+
+ TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+// try {
+// EFactory.eSet(rightElement, theDiff.getReference().getName(), target);
+
+ Command command = PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, rightElement, theDiff.getReference(), target);
+ domain.getCommandStack().execute(command );
+// } catch (final FactoryException e) {
+// EMFComparePlugin.log(e, true);
+// }
} else {
super.doUndoInTarget();
}
@@ -17,7 +51,24 @@ public class CReferenceOrderChangeMerger extends ReferenceOrderChangeMerger {
@Override
public void doApplyInOrigin() {
if(MergerUtils.usePapyrusMerger()) {
- throw new UnsupportedOperationException();
+ final ReferenceOrderChange theDiff = (ReferenceOrderChange)this.diff;
+ final EObject leftElement = theDiff.getLeftElement();
+
+ final Collection<EObject> target = Lists.newArrayList(Collections2.filter(theDiff.getLeftTarget(),
+ new Predicate<EObject>() {
+ public boolean apply(EObject input) {
+ return !input.eIsProxy()
+ || !DefaultMerger.isEMFCompareProxy(((InternalEObject)input).eProxyURI());
+ }
+ }));
+ TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+// try {
+// EFactory.eSet(leftElement, theDiff.getReference().getName(), target);
+ Command command = PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, leftElement, theDiff.getReference(), target);
+ domain.getCommandStack().execute(command );
+// } catch (final FactoryException e) {
+// EMFComparePlugin.log(e, true);
+// }
} else {
super.doApplyInOrigin();
}

Back to the top