blob: b6edf38f73536ceabd15e03a756702b355da5542 (
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
|
/**
* Copyright (c) 2007, 2009 Borland Software Corporation
*
* 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:
* Alexander Shatalin (Borland) - initial API and implementation
* Michael Golubev (Montages) - #386838 - migrate to Xtend2
*/
package aspects.xpt.diagram.editpolicies
import com.google.inject.Inject
import com.google.inject.Singleton
import metamodel.MetaModel
import org.eclipse.gmf.codegen.gmfgen.GenNode
import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet
import org.eclipse.papyrus.papyrusgmfgenextension.GenerateUsingElementTypeCreationCommand
import xpt.Common
import xpt.providers.ElementTypes
@Singleton class childContainerCreateCommand extends xpt.diagram.editpolicies.childContainerCreateCommand{
@Inject extension Common;
@Inject extension ElementTypes;
@Inject extension MetaModel;
override CharSequence childContainerCreateCommand(Iterable<? extends GenNode> nodes) '''
«IF ! nodes.empty»
«generatedMemberComment()»
protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
org.eclipse.gmf.runtime.emf.type.core.IElementType requestElementType = req.getElementType();
if(requestElementType == null) {
return super.getCreateCommand(req);
}
«FOR n : nodes»
«IF !n.sansDomain»
«childNodeCreateCommand(n.modelFacet, n)»
«ENDIF»
«ENDFOR»
return super.getCreateCommand(req);
}
«ENDIF»
'''
def childNodeCreateCommand(TypeModelFacet it,GenNode node)'''
if («accessElementType(node)» == requestElementType) {
«IF it.eResource.allContents.filter(typeof (GenerateUsingElementTypeCreationCommand)).size>0»
// adjust the containment feature
org.eclipse.emf.ecore.EReference containmentFeature = «MetaFeature(it.childMetaFeature)»;
req.setContainmentFeature(containmentFeature);
«ENDIF»
«IF it.eResource.allContents.filter(typeof (GenerateUsingElementTypeCreationCommand)).size>0»
return getGEFWrapper(getSemanticCreationCommand(req));
«ELSE»
return getGEFWrapper(new «node.getCreateCommandQualifiedClassName()»(req, org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getDiagramFrom(getHost())));
«ENDIF»
}
'''
}
|