blob: 74d90e726c37a0752b28c557505366e82b368841 (
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
|
/*******************************************************************************
* Copyright (c) 2011, 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.uml2.diff.internal.extension.clazz;
import org.eclipse.emf.compare.diff.metamodel.AbstractDiffExtension;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.compare.diff.metamodel.ModelElementChangeRightTarget;
import org.eclipse.emf.compare.uml2.diff.UML2DiffEngine;
import org.eclipse.emf.compare.uml2.diff.internal.extension.AbstractDiffExtensionFactory;
import org.eclipse.emf.compare.uml2diff.UML2DiffFactory;
import org.eclipse.emf.compare.uml2diff.UMLAssociationBranchChangeRightTarget;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Property;
/**
* Factory for UMLAssociationBranchChangeRightTarget.
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
public class UMLAssociationBranchChangeRightTargetFactory extends AbstractDiffExtensionFactory {
/**
* Constructor.
*
* @param engine
* The UML2 difference engine.
*/
public UMLAssociationBranchChangeRightTargetFactory(UML2DiffEngine engine) {
super(engine);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.compare.uml2.diff.internal.extension.IDiffExtensionFactory#handles(org.eclipse.emf.compare.diff.metamodel.DiffElement)
*/
public boolean handles(DiffElement input) {
return input instanceof ModelElementChangeRightTarget
&& ((ModelElementChangeRightTarget)input).getRightElement() instanceof Property
&& ((ModelElementChangeRightTarget)input).getRightElement().eContainer() instanceof Association
&& ((Association)((Property)((ModelElementChangeRightTarget)input).getRightElement())
.eContainer()).getMemberEnds().size() > 2;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.compare.uml2.diff.internal.extension.IDiffExtensionFactory#create(org.eclipse.emf.compare.diff.metamodel.DiffElement,
* org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer)
*/
public AbstractDiffExtension create(DiffElement input, EcoreUtil.CrossReferencer crossReferencer) {
final ModelElementChangeRightTarget changeRightTarget = (ModelElementChangeRightTarget)input;
final UMLAssociationBranchChangeRightTarget ret = UML2DiffFactory.eINSTANCE
.createUMLAssociationBranchChangeRightTarget();
ret.getHideElements().add(changeRightTarget);
ret.getRequires().add(changeRightTarget);
ret.setRemote(input.isRemote());
ret.setRightElement(changeRightTarget.getRightElement());
ret.setLeftParent(changeRightTarget.getLeftParent());
return ret;
}
}
|