Process to generate a gmf editor.

Instructions

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 :

Starting

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.

newGmfProcess1

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.

Bootstrapping

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.


create gmf plugin

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 GMF_TOOL=http://www.eclipse.org/gmf/2005/ToolDefinition
-- @nsURI ECORE=http://www.eclipse.org/emf/2002/Ecore

library ecore2gmfTool_custom;

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

};
-- the link targets feature : the identifier, and the feature as qname   
helper def : linkTarget() : Map(String,String) = Map{
 ('Model.mm','Model.mm'),
('AtlRes.superimpose','AtlRes.superimpose'),
('Call.in','Call.in'),

('Call.libarys','Call.libarys'),
('Call.artifact','Call.artifact'),
-- ('Call.enviorment','Call.enviorment'),
  ('Generator.uses','Generator.uses'),
 ('Generator.produce','Generator.produce'),
--('MMAlias.decoratedmodel','MMAlias.decoratedmodel'),
('ModelAlias','ModelAlias.decoratedmodel'),
('MMAlias','MMAlias.decoratedmodel'),
 ('Comment.documentedElement','Comment.documentedElement'),
 ('Callable.next','Callable.next'),
 ('Call.out','Call.out'),
('Call.res','Call.res')
,
--('ModelAlias.decoratedmodel','ModelAlias.decoratedmodel'),
-- ('MMAlias.decoratedmodel','MMAlias.decoratedmodel')
('ModelAlias','ModelAlias.decoratedmodel'),
 ('MMAlias','MMAlias.decoratedmodel')

--,
 
 
};
--the source of a link
helper def : linkSource() : Map(String,String) = Map{
--('ModelAlias','ModelAlias.decoratedmodel'),
--('MMAlias','MMAlias.decoratedmodel')
    --,
   
};
--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{
'Callable','Documentable'
    --'CallLog','DisconnectEvent','ConnectEvent','NewCallEvent','CallStateEventEvent'
};

helper def : excludedEReference() : Sequence(String) = Sequence{
'Call.enviorment'
};
helper def : excludedEAttributes() : Sequence(String) = Sequence{
'Calls.logDefault',
'Call.profile',
'Call.disableAttributeHelperCache',
'Call.printExecutionTime',
'Call.showSummary',
'Call.continueAfterErrors',
'Call.allowInterModelReferences',
'Model.isTemporary',
'ModelAlias.isTemporary',
'ModelAlias.uri',
'ModelAlias.name',
'MMAlias.isTemporary',
'MMAlias.uri',
'MMAlias.name',
'MMAlias.handler'
};

--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{
('Useit_Generator','ug')   
};
--the diagram element
helper def : diagram(): String = 'Calls';
-- the default viewpattern of the feature label
helper context ECORE!EAttribute  def : toDefaultViewPattern() : String =
--self.name+' : {0}'
''
;