/*******************************************************************************
* Copyright (c) 2006, 2012 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.compare.diff.internal.merge.impl;
import java.util.List;
import org.eclipse.emf.compare.EMFComparePlugin;
import org.eclipse.emf.compare.FactoryException;
import org.eclipse.emf.compare.diff.merge.DefaultMerger;
import org.eclipse.emf.compare.diff.metamodel.MoveModelElement;
import org.eclipse.emf.compare.util.EFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* Merger for a {@link MoveModelElement} operation.
*
* @author Laurent Goubet
*/
public class MoveModelElementMerger extends DefaultMerger {
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin()
*/
@SuppressWarnings("unchecked")
@Override
public void doApplyInOrigin() {
final MoveModelElement theDiff = (MoveModelElement)this.diff;
final EObject leftTarget = theDiff.getLeftTarget();
final EObject leftElement = theDiff.getLeftElement();
final EReference ref = theDiff.getRightElement().eContainmentFeature();
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