Graphical Modeling Framework/Models/GMFMap
- Show children elements from non-containment feature
- Generally, Containment Feature of Node Reference specifies where to put newly created child to, while Children Feature is there to find out where to take children from to display them. It's quite often that these two are the same, hence Children Feature defaults to value of Containment Feature.
- To show children from feature different from the one they are contained with, simply set it as Children Feature. You'll need to specify Containment Feature as well.
- Endless/recursive hierarchies
- ChildReference not necessarily owns node mapping, it's possible to point to existing NodeMapping, defined elsewhere. Reusing NodeMapping allows to create endless hierarchies of elements, e.g. StateMachine owns State (via states containment ref), and State owns other States (via substates containment). To get endless State hierarchy define TopNodeReference with states set as Containment Feature, which owns NodeMapping (referencing State and appropriate diagram node and palette element). ChildReference of the NodeMapping specifies substates as Containment Feature and the owning NodeMapping as its Referenced Child. That's it.
- Use same creation tool to create various diagram elements
- Few mappings can point to same tool definition in the .gmftool model. Transformation (.gmfmap -> .gmfgen) is smart enough to recognize that and creates only one tool capable of creating several metamodel types. It's not possible to use the same tool to create both nodes and links, though.
- Specialize domain element
- Sometimes you may EClass is not sufficient and there's need to further nail down what domain element to use. For example, ECore diagram's aggregation and association references - EReference with containment attrubute set to true should be visualized differently from those with containment set to false. In such case add Constraint to as MappingEntry.domainSpecialization. Though constraint may not be the best term, it's just what specialization is about - constrain domain element to particular kind. OCL is default language to express specialization, although Java and few others are supported.
- Note, with specialized domain elements there's often need to perform initializations that set appropriate attributes on element creation, see next session for details
- Initialize domain element
- Constrain link creation
- Validating domain model during edit ('Live' constraints)
- TopNodeReference and ChildReference. The major difference is that top node references may only own child NodeMapping, not reuse existing as it seems confusing to allow for that. If you like to reuse some child NodeMapping for top node, you can do it other way round, i.e. reuse top node for child. Reusing another top node is not possible (are there models with different containments/children features for same elements to justify this use-case?). Also, there's no much sense to define compartments for diagam immediate children (hmm, that might be enhancement request, though I never saw such uses...), hence another difference from ChildReference. Last, TopNodeReference has no parent node.
- EClass, not ElementType/whatever as domainElement?
GMFMap's POI (points of interest)
Node and Link Mapping
These elements tie visual, tooling and metamodel element together. It's essentially a diagram element, with visual icon to show, tool to create and domain element to back up. Node Mappings are kept separate from Node References because same diagram element (described with Node Mapping) may appear in different parent-child relationships (both domain and visual).
Concept of Node References
- Containment Feature
- - EReference with containment attribute set to true.
- Children Feature
- - generally, non-containment EReference, the same as Containment Feature unless explicitly set. Usually, this feature is read-only filtering view to values in Containment Feature(Think of EClass.eAttributes and EClass.eOperations - both EOperation and EAttribute are owned via eClass.eStructuralFeatures). Though this EReference may be containment reference different from Containment Feature, it doesn't sound like reasonable use-case
- Shows actual node mapping taken as child (either from ownedChild or referencedChild)
- There's no much sense to set both ownedChild and referencedChild properties.
Label Mapping Properties
- View Pattern -
- Edit Pattern -