blob: b91c9cb85fea6dea6b50a2c9bf0836dea0976bbc [file] [log] [blame]
/**
* Copyright (c) 2009, 2011, 2012 Borland Software Corporation & others
*
* 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:
* Artem Tikhomirov (Borland) - initial API and implementation
* Guillaume Hillairet (Montages A.G.)
*/
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/gmf/2006/mappings');
modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/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;
}
}