Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e6716d8b8d076ed4972236c49bda4abc2459ec94 (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
import xpt.NativeGenModelUtils;

import xpt.GenModelUtils;

modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";

library GenDiagram;

helper standaloneDomainModel(genDiagram : genModel::GenDiagram) : Boolean {
	return not genDiagram.editorGen.sameFileForDiagramAndModel and genDiagram.domainDiagramElement <> null
}

helper hasDocumentRoot(genDiagram : genModel::GenDiagram) : Boolean {
	return getDocumentRoot(genDiagram) <> null
}

helper getDocumentRoot(genDiagram : genModel::GenDiagram) : genModel_1::GenClass {
	return (if genDiagram.domainDiagramElement = null then null else getDocumentRoot(genDiagram.domainDiagramElement.genPackage) endif)
}

helper getDocumentRootSetFeature(genDiagram : genModel::GenDiagram) : genModel_1::GenFeature {
	return getDocumentRoot(genDiagram).genFeatures->select(f | isDocRootSetFeature(f, genDiagram.domainDiagramElement.ecoreClass))->first()
}

helper isDocRootSetFeature(gf : genModel_1::GenFeature, eType : ecore::EClass) : Boolean {
	return not isListType(gf) and gf.ecoreFeature.changeable and (-2 = gf.ecoreFeature.upperBound.oclAsType(Integer) and (gf.ecoreFeature.eClass().name = 'EReference' and gf.ecoreFeature.eType.oclAsType(ecore::EClass).isSuperTypeOf(eType)))
}

Back to the top