Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6cd1ab64dbf4c64cc2e834ded3b4133b079cdbf1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*****************************************************************************
 * Copyright (c) 2012 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.compare.merger.utils;

import java.util.Collection;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.compare.diff.merge.EMFCompareEObjectCopier;
import org.eclipse.emf.compare.diff.merge.service.MergeService;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.uml.merger.provider.PapyrusMergeCommandProvider;


public class PapyrusCompareEObjectCopier {

	private EMFCompareEObjectCopier copier = null;

	public PapyrusCompareEObjectCopier(final DiffElement diff) {
		copier = MergeService.getCopier(diff);
	}

	/**
	 * Adapted from copyReferenceValue(EReference targetReference, EObject target, EObject value,
	 * EObject matchedValue, int index)
	 * 
	 * @param targetReference
	 * @param target
	 * @param value
	 * @param matchedValue
	 * @param index
	 * @return
	 */
	public Command getCopyReferenceValueCommand(final EReference targetReference, final EObject target, final EObject value, final EObject matchedValue, final int index) {
		final TransactionalEditingDomain domain = MergerUtils.getEditingDomain();
		EObject actualValue = value;
		if(value == null && matchedValue != null) {
			//			handleLinkedResourceDependencyChange(matchedValue);
			//			actualValue = get(matchedValue);
			//TODO
			throw new UnsupportedOperationException("Not yet supported");
		}
		if(matchedValue != null) {
			this.copier.put(actualValue, matchedValue);

			final Object referenceValue = target.eGet(targetReference);
			if(referenceValue instanceof Collection<?>) {
				//TODO
				//				addAtIndex((Collection<EObject>)referenceValue, matchedValue, index);
				throw new UnsupportedOperationException("Not yet supported");
			} else {
				//				target.eSet(targetReference, matchedValue);
				return PapyrusMergeCommandProvider.INSTANCE.getSetCommand(domain, target, targetReference, targetReference);
			}
			//			return matchedValue;
		}
		//		return copyReferenceValue(targetReference, target, actualValue, index);
		//TODO
		throw new UnsupportedOperationException("Not yet supported");
	}


}

Back to the top