Process to generate a gmf editor.


A complex transformation process is the creation of a gmf editor. This is the process also used to generate this plug in. Like the gmf dashboard you can use it as an execution board for the whole transformation and generation process, but unlike it you can fully customize it, because this is an editor for such model. It's support inheriting what gmf not directly does. The big picture is M2M round tip, if you change your ecore model you can regenerate all resources. The main concept is convention over declaration. Only if you want to change the default behavior you need to define it. 

You can control the transformation in three ways :


You start by selecting your ecore model file and select New  -> other

new Gmf Process

You select the target container and the input model. If your project isn't an ATL project you can add the ATL nature to the project.


After finishing the wizard the nessesary files are created and you can open up the callchain_diagram file.

A folder gmf is created, it contains the transformations, a file xxx_custom.atl is created in the model folder, this file is the declaration part of the transformation, here you can define exceptions from the default behavior.

Also two launch configuration are created, one for bootstrapping and one for the main process.


The first time it is nessesary to create all resources, before you can start with the main generation process. The bootstrapping gmf diagram contains the transformation for this bootstrapping process. Just start the bootstrapToolTemplate call.

bootstrapping the gmf resources

Three models are created, a graphtemplate containing the default graphmappings, a custom graphmapping, and a tool model. The custom graphmapping will override the default one, so here you would define your exceptions from the default behavior.  Just rename your tool.gmftool to xxxx the tool model is quite simple so I had decided to directly use the customized model. With this copy of the tool model you will define your tool pallete as usual. In roundtip you will need to make the changes manually. But the tooling definition is about grouping items, and in my opinion the default editor, the EMF one, is a good editor for such task. 

Create the mapping and the genmodel

This is the main process cycle.

It starts by create and merging the definition data into the mapping file. We let the gmf generator create the genmodel, and refine it in a transformation. Afterwards we use the gmf generator again to produce the diagram plug in.


Customize the process

The main hook is the file xxx.atl it contains declarations of exceptions from the normal transformation process. 

So at first you will need to know the default process. 

Each eClass will be tranformed to a topNodeReference if, it's not the diagram node, it's not an type based link, it's not contain in an other eClass, and it's not excluded. For each topNodeReference a nodeMapping is created, with the resolved tool and the resolved diagramNode. An domainSpecialization ocl constrain is created linking the node tight to the eClass.

Each eAttribute will be transformed to a featureLabelMapping if, the eClass containing it is not excluded, and it self it not excluded. It will be linked with the corresponding diagramLabel and the viewPattern will be set to the defined value, mostly the default one.

An eReference will transformed to a referencedBaseLink if, it's not a containment reference, and of course it's not excluded.

The file based customizing.

-- @atlcompiler atl2006
-- @nsURI ECORE=

library ecore2gmfTool_custom;

-- elements displayed as link
helper def : linknames() : Sequence(String) = Sequence{
-- link containments : the link eclass , the feature it's stored in
helper def : linkContainments() : Map(String,String) = Map{
--    ('AtlRes','CallLineIdentifier.cliAccountAssociation')

-- the link targets feature : the identifier, and the feature as qname   
helper def : linkTarget() : Map(String,String) = Map{

-- ('Call.enviorment','Call.enviorment'),
-- ('MMAlias.decoratedmodel','MMAlias.decoratedmodel')

--the source of a link
helper def : linkSource() : Map(String,String) = Map{
--ocl constraint for a link can be defined here
-- annotaion : link.sourcecontraint
helper def : linkConstraint : Map(String, TupleType(source:String,target:String) )
= Map{
--('MMAlias', Tuple{source : String ='',target : String =''} )
--the custom view pattern  for feature labels (Qname,pattern)
helper def : customViewPatterns() : Map(String,String) = Map{

helper def : excludedEClasses : Sequence(String) = Sequence{

helper def : excludedEReference() : Sequence(String) = Sequence{
helper def : excludedEAttributes() : Sequence(String) = Sequence{

--helper context  def : NAME : TYPE =
helper def : refLink() : Map(String,String) = Map{
--    ('CliAccountAssociation','CliAccountAssociation.account')


--the custom figure name
helper def : customFigureName() : Map(String,String) = Map{
--the diagram element
helper def : diagram(): String = 'Calls';
-- the default viewpattern of the feature label
helper context ECORE!EAttribute  def : toDefaultViewPattern() : String =' : {0}'