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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************************
* Copyright (c) 2009, 2020 Borland Software Corporation, CEA LIST, Artal & others
*
* 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
* Guillaume Hillairet (Montages A.G.)
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
*/
import Utils;
import Mappings;
import DiagramRunTimeModel;
import PropertySheet;
import PreferencePages;
import Navigator;
import Actions;
import RichClientPlatformApp;
import Audits;
import Parsers;
modeltype GMFMAP uses mappings('http://www.eclipse.org/papyrus/gmf/2020/mappings');
modeltype GMFGEN uses gmfgen('http://www.eclipse.org/papyrus/gmf/2020/GenModel');
modeltype GENMODEL uses genmodel('http://www.eclipse.org/emf/2002/GenModel');
transformation Map2Gen(
in mapModel: GMFMAP,
in domainGenModel: GENMODEL,
in diagramRuntimeGenModel: GENMODEL,
out gmfgenModel: GMFGEN);
configuration property rcp: Boolean;
configuration property useMapMode: Boolean;
configuration property useFullRunTime: Boolean;
configuration property useInTransformationCodeGen: Boolean;
main() {
var mapRoot := mapModel.rootObjects()![GMFMAP::Mapping];
genModel := domainGenModel.rootObjects()![GENMODEL::GenModel];
Viewmaps::setMapMode(useMapMode);
useModeledViewmaps := not useInTransformationCodeGen;
var genEditor := mapRoot.map structure();
genEditor.diagram.palette := mapRoot.diagram.map palette();
genEditor.domainGenModel := mapRoot.diagram.domainModel.findGenPackage().genModel;
genEditor.plugin := mapRoot.map editorPlugin();
genEditor.editor := object GenEditorView {};
genEditor.diagramUpdater := object GenDiagramUpdater {};
genEditor.audits := mapRoot.audits.map audits(); -- these two should go before expression providers collection
genEditor.metrics := mapRoot.metrics.map metrics();
if not GMFGEN::GenParserImplementation.allInstances()->isEmpty() then {
genEditor.labelParsers := mapRoot.map createGenParsers()
} endif;
new DiagramRunTimeModel(diagramRuntimeGenModel, gmfgenModel).transform();
if not rcp then new Navigator(mapModel, gmfgenModel).transform() endif;
new PropertySheet(mapModel, gmfgenModel).transform();
new PreferencePages(mapModel, gmfgenModel).transform();
new Actions(mapModel, gmfgenModel).transform();
if rcp then new RichClientPlatformApp(mapModel, gmfgenModel).transform() endif;
-- collect orphan palette items and add them to the Default group.
var toolGroup := GMFGEN::ToolGroup.allInstances()->any(title = 'Default');
GMFGEN::ToolGroupItem.allInstances()->select(e | e.container().oclIsUndefined())->forEach(element) {
toolGroup.entries += element;
}
}
--
-- Editor Plugin
--
mapping GMFMAP::Mapping::editorPlugin() : GMFGEN::GenPlugin {
requiredPlugins := Set{'org.eclipse.gmf.tooling.runtime', 'org.eclipse.draw2d'};
if self.links->notEmpty() or GMFMAP::LabelMapping.allInstances()->notEmpty() then
requiredPlugins += 'org.eclipse.gmf.runtime.draw2d.ui'
endif;
self.diagram.diagramCanvas.figures->forEach(fg) {
if not fg.implementationBundle.oclIsUndefined() then {
result.requiredPlugins += fg.implementationBundle
} endif;
}
}
|