blob: bfae168b26dfffdddbf2fd555adb8fad0c400145 (
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
|
/*
* Copyright (c) 2010 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:
* Yann Tanguy (CEA LIST) - initial API and implementation
*
*/
modeltype gmfgen uses "http://www.eclipse.org/gmf/2009/GenModel";
modeltype papyrusgmfgenextension uses "http://www.eclipse.org/papyrus/2009/papyrusgmfgenextension";
library NodeConstraintUtils;
helper gmfgen::GenNode::hasNodeCreationConstraint() : Boolean {
return papyrusgmfgenextension::GenNodeConstraint.allInstances()
->select(v : papyrusgmfgenextension::GenNodeConstraint
| v.genNode->includes(self) and v.genConstraint <> null)
->size()<>0
}
helper gmfgen::GenNode::getNodeCreationConstraint() : papyrusgmfgenextension::GenNodeConstraint {
if(self.hasNodeCreationConstraint()) then {
return papyrusgmfgenextension::GenNodeConstraint.allInstances()
->select(v : papyrusgmfgenextension::GenNodeConstraint
| v.genNode->includes(self) and v.genConstraint <> null)
->asSequence()->first()
} endif;
return null;
}
helper gmfgen::TypeModelFacet::getOwningGenNode() : gmfgen::GenNode {
return gmfgen::GenNode.allInstances()
->select(v : gmfgen::GenNode | v.modelFacet = self)
->asSequence()->first()
}
helper gmfgen::GenNode::getNodeCreationConstraintBody() : String {
let nodeConstraint = self.getNodeCreationConstraint() in
if (self.hasNodeCreationConstraint() <> null) then {
if ((nodeConstraint.genConstraint <> null) and (nodeConstraint.genConstraint._body <> null)) then {
return nodeConstraint.genConstraint._body;
} endif;
} endif;
return "No GenNodeConstraint found.";
}
|