Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-04-12 09:14:25 +0000
committervlorenzo2012-04-12 09:14:25 +0000
commit58a37dc98e0bde9f9acf2f7916f6aa1b5f87bd88 (patch)
tree6bcb236b31ee4eb8622055dd79defaff5dd340b5 /sandbox/UMLCompareMergerExample
parent0eeab433ac205400994bf2ad88a38304ae315667 (diff)
downloadorg.eclipse.papyrus-58a37dc98e0bde9f9acf2f7916f6aa1b5f87bd88.tar.gz
org.eclipse.papyrus-58a37dc98e0bde9f9acf2f7916f6aa1b5f87bd88.tar.xz
org.eclipse.papyrus-58a37dc98e0bde9f9acf2f7916f6aa1b5f87bd88.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/.classpath7
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.project28
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF19
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/build.properties5
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/plugin.xml13
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/Activator.java55
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MergerUtils.java29
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexCommand.java74
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexRequest.java29
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/PapyrusMap.java83
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeLeftTargetMerger.java27
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeRightTargetMerger.java26
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeOrderChangeMerger.java25
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CDiffGroupMerger.java25
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeLeftTargetMerger.java138
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeRightTargetMerger.java25
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CMoveModelElementMerger.java106
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeLeftTargetMerger.java25
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeRightTargetMerger.java25
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java25
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateAttributeMerger.java70
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateReferenceMerger.java26
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/MergeCommandProvider.java230
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusMergeCommandProvider.java106
-rw-r--r--sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusUMLMergeProvider.java55
26 files changed, 1283 insertions, 0 deletions
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.classpath b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.classpath
new file mode 100644
index 00000000000..6ee16b50555
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry excluding="org/eclipse/papyrus/uml/merger/provider/MergeCommandProvider.java" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.project b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.project
new file mode 100644
index 00000000000..95abdd04718
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.compare.merger</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.settings/org.eclipse.jdt.core.prefs b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
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
new file mode 100644
index 00000000000..914a7a23080
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Payrus UML Merger
+Bundle-SymbolicName: org.eclipse.papyrus.uml.compare.merger;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.uml.compare.merger.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.compare.diff,
+ org.eclipse.papyrus.infra.core.log,
+ org.eclipse.emf.transaction,
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.papyrus.infra.gmfdiag.commands,
+ 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
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/build.properties b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/plugin.xml b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/plugin.xml
new file mode 100644
index 00000000000..5ac706ab66b
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.emf.compare.diff.mergerprovider">
+ <mergerprovider
+ fileExtension="uml"
+ mergerProviderClass="org.eclipse.papyrus.uml.merger.provider.PapyrusUMLMergeProvider"
+ priority="low">
+ </mergerprovider>
+ </extension>
+
+</plugin>
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/Activator.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/Activator.java
new file mode 100644
index 00000000000..3568c3b62b9
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/Activator.java
@@ -0,0 +1,55 @@
+package org.eclipse.papyrus.uml.compare.merger;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.compare.merger"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**the Papyrus log helper*/
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MergerUtils.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MergerUtils.java
new file mode 100644
index 00000000000..687741d4001
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MergerUtils.java
@@ -0,0 +1,29 @@
+package org.eclipse.papyrus.uml.compare.merger.utils;
+
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiPageEditorPart;
+import org.eclipse.papyrus.infra.tools.util.EditorHelper;
+import org.eclipse.ui.IEditorPart;
+
+public class MergerUtils {
+
+ private MergerUtils() {
+ //nothing to do
+ }
+
+ public static boolean usePapyrusMerger() {
+ return getEditingDomain()!=null;
+ }
+
+ public static TransactionalEditingDomain getEditingDomain() {
+ IEditorPart editor = EditorHelper.getCurrentEditor();
+ if(editor instanceof IMultiPageEditorPart) {
+ editor = ((IMultiPageEditorPart)editor).getActiveEditor();
+ }
+ if(editor instanceof IEditingDomainProvider) {
+ return (TransactionalEditingDomain)((IEditingDomainProvider)editor).getEditingDomain();
+ }
+ return null;
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexCommand.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexCommand.java
new file mode 100644
index 00000000000..5627ac48dee
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexCommand.java
@@ -0,0 +1,74 @@
+package org.eclipse.papyrus.uml.compare.merger.utils;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.emf.edit.command.MoveCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.internal.l10n.EMFTypeCoreMessages;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+
+//TODO move this class and create it in the service edit
+public class MoveWithIndexCommand extends MoveElementsCommand {
+
+ public MoveWithIndexCommand(MoveRequest request) {
+ super(request);
+ }
+
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ int index = getIndex();
+ if(index != -1) {
+ for(Iterator<?> i = getElementsToMove().keySet().iterator(); i.hasNext();) {
+ EObject element = (EObject)i.next();
+ EReference feature = getTargetFeature(element);
+
+ if(feature != null) {
+ if(FeatureMapUtil.isMany(getTargetContainer(), feature)) {
+ Object value = getTargetContainer().eGet(feature);
+ if(value instanceof List<?>) {
+ List<?> listValue = (List<?>)value;
+ int indexMax = listValue.size() - 1;
+ if(indexMax < index) {
+ //we add the element at the end of the list
+ ((Collection)getTargetContainer().eGet(feature)).add(element);
+ } else {
+ ((List)value).add(index, element);
+ }
+
+ } else {
+ ((Collection)getTargetContainer().eGet(feature)).add(element);
+ }
+ } else {
+ getTargetContainer().eSet(feature, element);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult(EMFTypeCoreMessages.moveElementsCommand_noTargetFeature);
+ }
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ return super.doExecuteWithResult(monitor, info);
+ }
+
+ /**
+ *
+ * @return
+ * the index for the move command
+ */
+ protected int getIndex() {
+ IEditCommandRequest req = getRequest();
+ if(req instanceof MoveWithIndexRequest) {
+ return ((MoveWithIndexRequest)req).getIndex();
+ }
+ return -1;
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexRequest.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexRequest.java
new file mode 100644
index 00000000000..de0533cf927
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/MoveWithIndexRequest.java
@@ -0,0 +1,29 @@
+package org.eclipse.papyrus.uml.compare.merger.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+
+//TODO : move this class
+/**
+ *
+ * Created for EMF-Compare, for MoveModelElementMerger
+ *
+ */
+public class MoveWithIndexRequest extends MoveRequest {
+
+ private int index;
+
+ //TODO : and the other constructor?
+ public MoveWithIndexRequest(TransactionalEditingDomain editingDomain, EObject targetContainer, EReference targetFeature, EObject elementToMove, final int index) {
+ super(editingDomain, targetContainer, targetFeature, elementToMove);
+ this.index = index;
+ }
+
+
+ public int getIndex() {
+ return index;
+ }
+
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/PapyrusMap.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/PapyrusMap.java
new file mode 100644
index 00000000000..e81b2962341
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/compare/merger/utils/PapyrusMap.java
@@ -0,0 +1,83 @@
+package org.eclipse.papyrus.uml.compare.merger.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.papyrus.uml.compare.merger.Activator;
+
+/**
+ * This map log an error when a wanted element is unknown in the map
+ *
+ * @author VL222926
+ *
+ * @param <K>
+ * @param <V>
+ */
+public class PapyrusMap<K, V> extends HashMap<K, V> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructs an empty <tt>HashMap</tt> with the specified initial
+ * capacity and load factor.
+ *
+ * @param initialCapacity
+ * The initial capacity.
+ * @param loadFactor
+ * The load factor.
+ * @throws IllegalArgumentException
+ * if the initial capacity is negative
+ * or the load factor is nonpositive.
+ */
+ public PapyrusMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Constructs an empty <tt>HashMap</tt> with the specified initial
+ * capacity and the default load factor (0.75).
+ *
+ * @param initialCapacity
+ * the initial capacity.
+ * @throws IllegalArgumentException
+ * if the initial capacity is negative.
+ */
+ public PapyrusMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Constructs an empty <tt>HashMap</tt> with the default initial capacity
+ * (16) and the default load factor (0.75).
+ */
+ public PapyrusMap() {
+ super();
+ }
+
+ /**
+ * Constructs a new <tt>HashMap</tt> with the same mappings as the
+ * specified <tt>Map</tt>. The <tt>HashMap</tt> is created with
+ * default load factor (0.75) and an initial capacity sufficient to
+ * hold the mappings in the specified <tt>Map</tt>.
+ *
+ * @param m
+ * the map whose mappings are to be placed in this map.
+ * @throws NullPointerException
+ * if the specified map is null.
+ */
+ public PapyrusMap(Map<? extends K, ? extends V> m) {
+ super(m);
+ }
+
+ @Override
+ public V get(Object key) {
+ V obj = super.get(key);
+ if(obj == null) {
+ Activator.log.error("The following element is unknown in the map : " + key, new NullPointerException());
+ }
+ return obj;
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeLeftTargetMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeLeftTargetMerger.java
new file mode 100644
index 00000000000..2adca83ec58
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeLeftTargetMerger.java
@@ -0,0 +1,27 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.AttributeChangeLeftTargetMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CAttributeChangeLeftTargetMerger extends AttributeChangeLeftTargetMerger {
+
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeRightTargetMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeRightTargetMerger.java
new file mode 100644
index 00000000000..bb039574c37
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeChangeRightTargetMerger.java
@@ -0,0 +1,26 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.AttributeChangeRightTargetMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CAttributeChangeRightTargetMerger extends AttributeChangeRightTargetMerger {
+
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeOrderChangeMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeOrderChangeMerger.java
new file mode 100644
index 00000000000..56fd7656441
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CAttributeOrderChangeMerger.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.AttributeOrderChangeMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CAttributeOrderChangeMerger extends AttributeOrderChangeMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CDiffGroupMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CDiffGroupMerger.java
new file mode 100644
index 00000000000..0cf94702413
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CDiffGroupMerger.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CDiffGroupMerger extends DiffGroupMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeLeftTargetMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeLeftTargetMerger.java
new file mode 100644
index 00000000000..9a84a254bc4
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeLeftTargetMerger.java
@@ -0,0 +1,138 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.compare.EMFComparePlugin;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.internal.merge.impl.ModelElementChangeLeftTargetMerger;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+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.EReference;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CModelElementChangeLeftTargetMerger extends ModelElementChangeLeftTargetMerger {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ */
+ @Override
+ protected void doApplyInOrigin() {
+
+ if(MergerUtils.usePapyrusMerger()) {
+ final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)this.diff;
+ final EObject element = theDiff.getLeftElement();
+ TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+ Command cmd = PapyrusMergeCommandProvider.INSTANCE.getDestroyCommand(domain, element);
+ domain.getCommandStack().execute(cmd);
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+
+ @Override
+ protected void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+ CompoundCommand cmd = new CompoundCommand("ModelElementChangeLeftTargetCommand");
+ final ModelElementChangeLeftTarget theDiff = (ModelElementChangeLeftTarget)this.diff;
+ // we should copy the element to the Origin one.
+ final EObject origin = theDiff.getRightParent();
+ final EObject element = theDiff.getLeftElement();
+ final EObject newOne = copy(element);
+ final EReference ref = element.eContainmentFeature();
+ if(ref != null) {
+ // try {
+ int elementIndex = -1;
+ if(ref.isMany()) {
+ final Object containmentRefVal = element.eContainer().eGet(ref);
+ if(containmentRefVal instanceof List<?>) {
+ @SuppressWarnings("unchecked")
+ final List<EObject> listVal = (List<EObject>)containmentRefVal;
+ elementIndex = listVal.indexOf(element);
+ }
+ }
+
+ // EFactory.eAdd(origin, ref.getName(), newOne, elementIndex, true);
+
+
+ if(elementIndex != -1) {
+ List<Object> newList = new ArrayList<Object>();
+ Collections.copy(newList, ((List<Object>)origin.eGet(ref)));
+ newList.add(elementIndex, newOne);
+ //testable with the example ModelElementChangeLeftTargetExample1
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, origin, ref, newList));
+ } else {
+ //testable with the example ModelElementChangeLeftTargetExample2
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, origin, ref, newOne));
+ }
+ // setXMIID(newOne, getXMIID(element));
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getSetXMIIDCommand(domain, newOne, getXMIID(element)));
+ // } catch (final FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ } else if(origin == null && getDiffModel().getRightRoots().size() > 0) {
+ //TODO : no example for this case
+ // getDiffModel().getRightRoots().get(0).eResource().getContents().add(newOne);
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getAddToResourceCommand(domain, getDiffModel().getRightRoots().get(0).eResource(), newOne));
+
+ } else if(origin != null) {
+ //TODO : no example for this case
+ // origin.eResource().getContents().add(newOne);
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getAddToResourceCommand(domain, origin.eResource(), newOne));
+
+
+ } else {
+ // FIXME throw exception : couldn't merge this
+ }
+ // we should now have a look for RemovedReferencesLinks needing elements to apply
+ final Iterator<EObject> siblings = getDiffModel().eAllContents();
+ while(siblings.hasNext()) {
+ final Object op = siblings.next();
+ if(op instanceof ReferenceChangeLeftTarget) {
+ //TODO
+ final ReferenceChangeLeftTarget link = (ReferenceChangeLeftTarget)op;
+ // now if I'm in the target References I should put my copy in the origin
+ if(link.getRightTarget() != null && link.getRightTarget() == element) {
+ link.setLeftTarget(newOne);
+ }
+ //TODO
+ throw new UnsupportedOperationException();
+ } else if(op instanceof ReferenceOrderChange) {
+
+ final ReferenceOrderChange link = (ReferenceOrderChange)op;
+ if(link.getRightElement() == origin && link.getReference() == ref) {
+ final ListIterator<EObject> targetIterator = link.getRightTarget().listIterator();
+ boolean replaced = false;
+ while(!replaced && targetIterator.hasNext()) {
+ final EObject target = targetIterator.next();
+ if(target.eIsProxy() && equalProxyURIs(((InternalEObject)target).eProxyURI(), EcoreUtil.getURI(element))) {
+ targetIterator.set(newOne);
+ replaced = true;
+ }
+ }
+ }
+ throw new UnsupportedOperationException();
+ }
+ }
+ domain.getCommandStack().execute(cmd);
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeRightTargetMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeRightTargetMerger.java
new file mode 100644
index 00000000000..ae7220b0279
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CModelElementChangeRightTargetMerger.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.ModelElementChangeRightTargetMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CModelElementChangeRightTargetMerger extends ModelElementChangeRightTargetMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CMoveModelElementMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CMoveModelElementMerger.java
new file mode 100644
index 00000000000..10d6fe6c078
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CMoveModelElementMerger.java
@@ -0,0 +1,106 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.compare.diff.internal.merge.impl.MoveModelElementMerger;
+import org.eclipse.emf.compare.diff.metamodel.MoveModelElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+/**
+ *
+ * Created for EMF-Compare, for MoveModelElementMerger
+ *
+ */
+public class CMoveModelElementMerger extends MoveModelElementMerger {
+
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ final MoveModelElement theDiff = (MoveModelElement)this.diff;
+ final EObject rightTarget = theDiff.getRightTarget();
+ final EObject rightElement = theDiff.getRightElement();
+ final EReference ref = theDiff.getLeftElement().eContainmentFeature();
+ CompoundCommand cmd = new CompoundCommand("doUndoInTarget for MoveModelElementCommand");
+ TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+ if(ref != null) {
+ // ordering handling:
+ int index = -1;
+ final EObject leftElementParent = theDiff.getLeftElement().eContainer();
+ final Object leftRefValue = leftElementParent.eGet(ref);
+ if(leftRefValue instanceof List) {
+ final List<Object> refLeftValueList = (List<Object>)leftRefValue;
+ index = refLeftValueList.indexOf(theDiff.getLeftElement());
+ //testable with MoveModelElementExample1
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveWithIndexCommand(domain, rightTarget, rightTarget, ref, rightElement, index));
+ }else{
+ // EcoreUtil.remove(rightElement);
+ // EFactory.eAdd(rightTarget, ref.getName(), rightElement, index, true);
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveCommand(domain, rightTarget, rightTarget, ref, rightElement));
+ }
+ // try {
+ final String elementID = getXMIID(rightElement);
+
+ // setXMIID(rightElement, elementID);
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getSetXMIIDCommand(domain, rightElement, elementID));
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ domain.getCommandStack().execute(cmd);
+ } else {
+ // shouldn't be here
+ assert false;
+ }
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ final MoveModelElement theDiff = (MoveModelElement)this.diff;
+ final EObject leftTarget = theDiff.getLeftTarget();
+ final EObject leftElement = theDiff.getLeftElement();
+ final EReference ref = theDiff.getRightElement().eContainmentFeature();
+ CompoundCommand cmd = new CompoundCommand("doApplyInOrigin for MoveModelElementCommand");
+ TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+ if(ref != null) {
+ // ordering handling:
+ int index = -1;
+ final EObject rightElementParent = theDiff.getRightElement().eContainer();
+ final Object rightRefValue = rightElementParent.eGet(ref);
+ if(rightRefValue instanceof List) {
+ final List<Object> refRightValueList = (List<Object>)rightRefValue;
+ index = refRightValueList.indexOf(theDiff.getRightElement());
+ //testable with MoveModelElementExample1
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveWithIndexCommand(domain, leftTarget, leftTarget, ref, leftElement, index));
+ }else{
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getMoveCommand(domain, leftTarget, leftTarget, ref, leftElement));
+ }
+
+ // try {
+ // We'll store the element's ID because moving an element deletes its XMI ID
+ final String elementID = getXMIID(leftElement);
+ // EcoreUtil.remove(leftElement);
+ // EFactory.eAdd(leftTarget, ref.getName(), leftElement, index, true);
+
+ // Sets anew the element's ID
+ // setXMIID(leftElement, elementID);
+ cmd.append(PapyrusMergeCommandProvider.INSTANCE.getSetXMIIDCommand(domain, leftElement, elementID));
+ // } catch (FactoryException e) {
+ // EMFComparePlugin.log(e, true);
+ // }
+ domain.getCommandStack().execute(cmd);
+ } else {
+ // shouldn't be here
+ assert false;
+ }
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeLeftTargetMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeLeftTargetMerger.java
new file mode 100644
index 00000000000..6eb42fc36dc
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeLeftTargetMerger.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.ReferenceChangeLeftTargetMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CReferenceChangeLeftTargetMerger extends ReferenceChangeLeftTargetMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeRightTargetMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeRightTargetMerger.java
new file mode 100644
index 00000000000..65dbe24a852
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceChangeRightTargetMerger.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.ReferenceChangeRightTargetMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CReferenceChangeRightTargetMerger extends ReferenceChangeRightTargetMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
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
new file mode 100644
index 00000000000..f440859e7e1
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CReferenceOrderChangeMerger.java
@@ -0,0 +1,25 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.ReferenceOrderChangeMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CReferenceOrderChangeMerger extends ReferenceOrderChangeMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateAttributeMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateAttributeMerger.java
new file mode 100644
index 00000000000..cb386170b74
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateAttributeMerger.java
@@ -0,0 +1,70 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.FactoryException;
+import org.eclipse.emf.compare.diff.internal.merge.impl.UpdateAttributeMerger;
+import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.compare.util.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.uml.compare.merger.Activator;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CUpdateAttributeMerger extends UpdateAttributeMerger {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
+ */
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ final TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+ final UpdateAttribute theDiff = (UpdateAttribute)this.diff;
+ final EObject element = theDiff.getRightElement();
+ final EObject origin = theDiff.getLeftElement();
+ final EAttribute attr = theDiff.getAttribute();
+
+ Command cmd = null;
+ try {
+ cmd = PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, origin, origin.eClass().getEStructuralFeature(attr.getName()), EFactory.eGet(element, attr.getName()));
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ domain.getCommandStack().execute(cmd);
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget()
+ */
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ final TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
+ final UpdateAttribute theDiff = (UpdateAttribute)this.diff;
+ final EObject element = theDiff.getRightElement();
+ final EObject origin = theDiff.getLeftElement();
+ final EAttribute attr = theDiff.getAttribute();
+ Command cmd = null;
+ try {
+ cmd = PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, element, element.eClass().getEStructuralFeature(attr.getName()), EFactory.eGet(origin, attr.getName()));
+ } catch (final FactoryException e) {
+ Activator.log.error(e);
+ }
+ domain.getCommandStack().execute(cmd);
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateReferenceMerger.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateReferenceMerger.java
new file mode 100644
index 00000000000..dcc6b0acfae
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/CUpdateReferenceMerger.java
@@ -0,0 +1,26 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.compare.diff.internal.merge.impl.UpdateReferenceMerger;
+import org.eclipse.papyrus.uml.compare.merger.utils.MergerUtils;
+
+
+public class CUpdateReferenceMerger extends UpdateReferenceMerger {
+ @Override
+ public void doUndoInTarget() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doUndoInTarget();
+ }
+ }
+
+ @Override
+ public void doApplyInOrigin() {
+ if(MergerUtils.usePapyrusMerger()) {
+ throw new UnsupportedOperationException();
+ } else {
+ super.doApplyInOrigin();
+ }
+ }
+}
+
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/MergeCommandProvider.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/MergeCommandProvider.java
new file mode 100644
index 00000000000..81adf206780
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/MergeCommandProvider.java
@@ -0,0 +1,230 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChange;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.AttributeOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.ConflictingDiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChange;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.MoveModelElement;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChange;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.ResourceDependencyChange;
+import org.eclipse.emf.compare.diff.metamodel.ResourceDependencyChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ResourceDependencyChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ResourceDiff;
+import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
+import org.eclipse.emf.compare.diff.metamodel.UpdateContainmentFeature;
+import org.eclipse.emf.compare.diff.metamodel.UpdateModelElement;
+import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
+import org.eclipse.emf.compare.diff.metamodel.impl.AttributeChangeImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+
+public class MergeCommandProvider {//TODO create an interface?
+
+ public Command getMergeCommand(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain, final EObject elementToDestroy) {
+ Command cmd = null;
+ if(diffElement instanceof AttributeChangeImpl) {
+ cmd = getMergeCommandForAttributeChange(container, confirmationRequired, (AttributeChange)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ConflictingDiffElement) {
+ cmd = getMergeCommandForConflictingDiffElement(container, confirmationRequired, (ConflictingDiffElement)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof DiffGroup) {
+ cmd = getMergeCommandForDiffGroup(container, confirmationRequired, (DiffGroup)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ModelElementChange) {
+ cmd = getMergeCommandForModelElementChange(container, confirmationRequired, (ModelElementChange)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ReferenceChange) {
+ cmd = getMergeCommandForReferenceChange(container, confirmationRequired, (ReferenceChange)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ResourceDiff) {
+ cmd = getMergeCommandForResourceDiff(container, confirmationRequired, (ResourceDiff)diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO log an error;
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForAttributeChange(final Object container, final boolean confirmationRequired, final AttributeChange diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ Command cmd = null;
+ if(diffElement instanceof AttributeChangeLeftTarget) {
+ cmd = getMergeCommandForAttributeChangeLeftTarget(container, confirmationRequired, diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof AttributeChangeRightTarget) {
+ cmd = getMergeCommandForAttributeChangeRightTarget(container, confirmationRequired, diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof AttributeOrderChange) {
+ cmd = getMergeCommandForAttributeOrderChange(container, confirmationRequired, diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof UpdateAttribute) {
+ cmd = getMergeCommandForUpdateAttribute(container, confirmationRequired, diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForAttributeChangeLeftTarget(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {//TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForAttributeChangeRightTarget(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForAttributeOrderChange(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {//TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForUpdateAttribute(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForConflictingDiffElement(final Object container, final boolean confirmationRequired, final ConflictingDiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForDiffGroup(final Object container, final boolean confirmationRequired, final DiffGroup diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForModelElementChange(final Object container, final boolean confirmationRequired, final ModelElementChange diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ Command cmd = null;
+ if(diffElement instanceof ModelElementChangeLeftTarget) {
+ cmd = getMergeCommandForModelElementChangeLeftTarget(container, confirmationRequired, (ModelElementChangeLeftTarget)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ModelElementChangeRightTarget) {
+ cmd = getMergeCommandForModelElementChangeRightTarget(container, confirmationRequired, (ModelElementChangeRightTarget)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof UpdateModelElement) {
+ cmd = getMergeCommandForUpdateModelElement(container, confirmationRequired, diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForModelElementChangeLeftTarget(final Object container, final boolean confirmationRequired, final ModelElementChangeLeftTarget diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+
+ return null;
+ }
+
+ protected Command getMergeCommandForModelElementChangeRightTarget(final Object container, final boolean confirmationRequired, final ModelElementChangeRightTarget diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForUpdateModelElement(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ Command cmd = null;
+ if(diffElement instanceof MoveModelElement) {
+ cmd = getMergeCommandForMoveModelElement(container, confirmationRequired, (MoveModelElement)diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForMoveModelElement(final Object container, final boolean confirmationRequired, final MoveModelElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ Command cmd = null;
+ if(diffElement instanceof UpdateContainmentFeature) {
+ cmd = getMergeCommandForUpdateContainmentFeature(container, confirmationRequired, (UpdateContainmentFeature)diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+
+ }
+
+ protected Command getMergeCommandForUpdateContainmentFeature(final Object container, final boolean confirmationRequired, final UpdateContainmentFeature diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForReferenceChange(final Object container, final boolean confirmationRequired, final ReferenceChange diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {//TODO
+ Command cmd = null;
+ if(diffElement instanceof ReferenceChangeLeftTarget) {
+ cmd = getMergeCommandForReferenceChangeLeftTarget(container, confirmationRequired, (ReferenceChangeLeftTarget)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ReferenceChangeRightTarget) {
+ cmd = getMergeCommandForReferenceChangeRightTarget(container, confirmationRequired, (ReferenceChangeRightTarget)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ReferenceOrderChange) {
+ cmd = getMergeCommandForReferenceOrderChange(container, confirmationRequired, (ReferenceOrderChange)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof UpdateReference) {
+ cmd = getMergeCommandForUpdateReference(container, confirmationRequired, (UpdateReference)diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForReferenceChangeLeftTarget(final Object container, final boolean confirmationRequired, final ReferenceChangeLeftTarget diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForReferenceChangeRightTarget(final Object container, final boolean confirmationRequired, final ReferenceChangeRightTarget diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForReferenceOrderChange(final Object container, final boolean confirmationRequired, final ReferenceOrderChange diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForUpdateReference(final Object container, final boolean confirmationRequired, final UpdateReference diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForResourceDiff(final Object container, final boolean confirmationRequired, final ResourceDiff diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ Command cmd = null;
+ if(diffElement instanceof ResourceDependencyChange) {
+ cmd = getMergeCommandForResourceDependencyChange(container, confirmationRequired, diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForResourceDependencyChange(final Object container, final boolean confirmationRequired, final DiffElement diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {//TODO
+ Command cmd = null;
+ if(diffElement instanceof ResourceDependencyChangeLeftTarget) {
+ cmd = getMergeCommandForResourceDependencyChangeLeftTarget(container, confirmationRequired, (ResourceDependencyChangeLeftTarget)diffElement, leftToRight, editingDomain);
+ } else if(diffElement instanceof ResourceDependencyChangeRightTarget) {
+ cmd = getMergeCommandForResourceDependencyChangeRightTarget(container, confirmationRequired, (ResourceDependencyChangeRightTarget)diffElement, leftToRight, editingDomain);
+ } else {
+ //TODO
+ }
+ return cmd;
+ }
+
+ protected Command getMergeCommandForResourceDependencyChangeLeftTarget(final Object container, final boolean confirmationRequired, final ResourceDependencyChangeLeftTarget diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+ protected Command getMergeCommandForResourceDependencyChangeRightTarget(final Object container, final boolean confirmationRequired, final ResourceDependencyChangeRightTarget diffElement, final boolean leftToRight, final TransactionalEditingDomain editingDomain) {
+ //TODO
+ return null;
+ }
+
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusMergeCommandProvider.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusMergeCommandProvider.java
new file mode 100644
index 00000000000..6f4a970b807
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusMergeCommandProvider.java
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.merger.provider;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.compare.merger.utils.MoveWithIndexCommand;
+import org.eclipse.papyrus.uml.compare.merger.utils.MoveWithIndexRequest;
+
+
+public class PapyrusMergeCommandProvider {
+
+ public static PapyrusMergeCommandProvider INSTANCE = new PapyrusMergeCommandProvider();
+
+ private PapyrusMergeCommandProvider() {
+
+ }
+
+ public Command getDestroyCommand(final TransactionalEditingDomain domain, final EObject element) {
+ final IEditCommandRequest request = new DestroyElementRequest(domain, element, false);
+ return getCommand(element, request);
+ }
+
+ //TODO elementToEdit and targetContainer are the same
+ public Command getMoveCommand(final TransactionalEditingDomain domain, final EObject elementToEdit, final EObject targetContainer, final EReference targetFeature, final EObject elementToMove) {
+ final IEditCommandRequest request = new MoveRequest(domain, targetContainer, targetFeature, elementToMove);
+ return getCommand(elementToEdit, request);
+ }
+
+ private Command getCommand(final EObject elementToEdit, final IEditCommandRequest request) {
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToEdit);
+ if(request instanceof MoveWithIndexRequest) {//TODO remove this test when the move with index will be in the service edit
+ return new GMFtoEMFCommandWrapper(new MoveWithIndexCommand((MoveRequest)request));
+ }
+ if(provider != null) {
+ return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ }
+ return null;
+ }
+
+ public Command getSetCommand(final TransactionalEditingDomain domain, final EObject element, final EStructuralFeature feature, final Object value) {
+ final IEditCommandRequest request = new SetRequest(domain, element, feature, value);
+ return getCommand(element, request);
+ }
+
+ public Command getSetXMIIDCommand(final TransactionalEditingDomain domain, final EObject element, final String id) {
+ //TODO change for an EMFCommand
+ return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Set XMI Command", null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if(element != null && element.eResource() instanceof XMIResource) {
+ ((XMIResource)element.eResource()).setID(element, id);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ });
+
+ }
+
+ public Command getAddToResourceCommand(final TransactionalEditingDomain domain, final Resource res, final EObject eobjectToAdd) {
+ //TODO change for an EMFCommand
+ return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Add EObject to Resource Command", null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ res.getContents().add(eobjectToAdd);
+ return CommandResult.newOKCommandResult();
+ }
+ });
+ }
+
+ //TODO elementToEdit and targetContainer are the same
+ public Command getMoveWithIndexCommand(final TransactionalEditingDomain domain, final EObject elementToEdit, final EObject targetContainer, final EReference targetFeature, final EObject elementToMove, final int index) {
+ final IEditCommandRequest request = new MoveWithIndexRequest(domain, targetContainer, targetFeature, elementToMove, index);
+ return getCommand(elementToEdit, request);
+ }
+}
diff --git a/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusUMLMergeProvider.java b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusUMLMergeProvider.java
new file mode 100644
index 00000000000..ca163de43a0
--- /dev/null
+++ b/sandbox/UMLCompareMergerExample/org.eclipse.papyrus.uml.compare.merger/src/org/eclipse/papyrus/uml/merger/provider/PapyrusUMLMergeProvider.java
@@ -0,0 +1,55 @@
+package org.eclipse.papyrus.uml.merger.provider;
+
+import java.util.Map;
+
+import org.eclipse.emf.compare.diff.merge.IMerger;
+import org.eclipse.emf.compare.diff.merge.IMergerProvider;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.AttributeChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.AttributeOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.DiffElement;
+import org.eclipse.emf.compare.diff.metamodel.DiffGroup;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.MoveModelElement;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeLeftTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceChangeRightTarget;
+import org.eclipse.emf.compare.diff.metamodel.ReferenceOrderChange;
+import org.eclipse.emf.compare.diff.metamodel.UpdateAttribute;
+import org.eclipse.emf.compare.diff.metamodel.UpdateReference;
+import org.eclipse.papyrus.uml.compare.merger.utils.PapyrusMap;
+
+
+public class PapyrusUMLMergeProvider implements IMergerProvider{
+ /**
+ * This map keeps a bridge between a given {@link DiffElement}'s class and the most accurate merger's
+ * class for that particular {@link DiffElement}.
+ */
+ private Map<Class<? extends DiffElement>, Class<? extends IMerger>> mergerTypes;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.diff.merge.IMergerProvider#getMergers()
+ */
+ public Map<Class<? extends DiffElement>, Class<? extends IMerger>> getMergers() {
+ if (mergerTypes == null) {
+ mergerTypes = new PapyrusMap<Class<? extends DiffElement>, Class<? extends IMerger>>();
+ mergerTypes.put(DiffGroup.class, CDiffGroupMerger.class);
+ mergerTypes.put(ModelElementChangeRightTarget.class, CModelElementChangeRightTargetMerger.class);
+ mergerTypes.put(ModelElementChangeLeftTarget.class, CModelElementChangeLeftTargetMerger.class);
+ mergerTypes.put(MoveModelElement.class, CMoveModelElementMerger.class);
+ mergerTypes.put(ReferenceChangeRightTarget.class, CReferenceChangeRightTargetMerger.class);
+ mergerTypes.put(ReferenceChangeLeftTarget.class, CReferenceChangeLeftTargetMerger.class);
+ mergerTypes.put(UpdateReference.class, CUpdateReferenceMerger.class);
+ mergerTypes.put(AttributeChangeRightTarget.class, CAttributeChangeRightTargetMerger.class);
+ mergerTypes.put(AttributeChangeLeftTarget.class, CAttributeChangeLeftTargetMerger.class);
+ mergerTypes.put(UpdateAttribute.class, CUpdateAttributeMerger.class);
+ mergerTypes.put(ReferenceOrderChange.class, CReferenceOrderChangeMerger.class);
+ mergerTypes.put(AttributeOrderChange.class, CAttributeOrderChangeMerger.class);
+ }
+ return mergerTypes;
+ }
+
+
+}

Back to the top