/******************************************************************************* * 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 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.UpdateAttribute; import org.eclipse.emf.compare.util.EFactory; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; /** * Merger for an {@link UpdateAttribute}. * * @author Laurent Goubet */ public class UpdateAttributeMerger extends DefaultMerger { /** * {@inheritDoc} * * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doApplyInOrigin() */ @Override public void doApplyInOrigin() { final UpdateAttribute theDiff = (UpdateAttribute)this.diff; final EObject element = theDiff.getRightElement(); final EObject origin = theDiff.getLeftElement(); final EAttribute attr = theDiff.getAttribute(); try { EFactory.eSet(origin, attr.getName(), EFactory.eGet(element, attr.getName())); } catch (FactoryException e) { EMFComparePlugin.log(e, true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#doUndoInTarget() */ @Override public void doUndoInTarget() { final UpdateAttribute theDiff = (UpdateAttribute)this.diff; final EObject element = theDiff.getRightElement(); final EObject origin = theDiff.getLeftElement(); final EAttribute attr = theDiff.getAttribute(); try { EFactory.eSet(element, attr.getName(), EFactory.eGet(origin, attr.getName())); } catch (FactoryException e) { EMFComparePlugin.log(e, true); } } }