29 déc. 2011

Extract relevant elements from a diagram

I would like to introduce in this post a new feature which will be available in the next release of Gendoc2.
This feature makes possible to extract elements you desire in a diagram.

This example will generate a part of the UML Metamodel documentation.
The diagram realized with MDT Papyrus is presented bellow:
This diagram displays some information about Events, Activity Nodes and Operations. For the documentation we only want to display the elements linked to the Signal Event and the Call Event meta classes.

This is now possible using new methods in TOPCASED and GMF bundles.
This is the code to use in your gendoc2 template :

  1. The diagram is get using getPapyrusDiagrams() method
  2. A list of visibleElements is computed using a focused class (SignalEvent or Call Event)
    • [let visibleElements : Set(uml::Class) = Set{focus}->union(focus.superClass)->union(focus.superClass->closure(superClass)->union(focus.getAssociations().memberEnd->select(type <> focus).type->asSet()))]
  3. The list of visible elements is used by the getDiagram method
  4. Finally the elements visible in the diagram are listed and for each element the documentation is displayed
The result is visible bellow