Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 06f9dea6566af732d5823891bb229d2432b79c20 (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
/******************************************************************************
 * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/ 
 * 
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors: 
 *    Artem Tikhomirov (Borland) - initial API and implementation
 *    Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
 *****************************************************************************/

import gmf.GenModelUtils;

modeltype gmfgen uses "http://www.eclipse.org/papyrus/gmf/2020/GenModel";
modeltype genmodel uses "http://www.eclipse.org/emf/2002/GenModel";
modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";

library GenDiagram;

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

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

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

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

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

Back to the top