IElementCompositorService should be used to compose model elements that have been instantiated programmatically
Rationale
- The current resolution of #2208 consists of triggering the
construction of the annotations a newly constructed model element
when it is hooked to the existing model. This is implemented in
HierarchicElementCompositorBase.compose()
that must be called from all derived compositors. - However, this approach can only work if compositors / the
IElementCompositorService
are actually used. This currently is the case when models are created manually using the editor, but most model-transformations directly callcontainer.getContainedElements().add(newChild)
- The same problem also exists for hooking programmatically
instantiated
Connector
s andConnection
s to the model.
Further analysis
- This problem could be considered as an evidence that the
IElementCompositorService
(along with itsCompositor
s) actually should be moved the model plugins since it imposes and constructively ensures) constraints on the structure of model instances. - Ideally, the direct (low-level) access of the lists containing
IHierarchicElement
s’ children, connectors and connections should be prevented - Alternatively, the construction of annotations could be ensured in
HierarchicElementCompositorBase.compose()
, but in the factory constructing the respective model elemnent (e.g., by changing the EMF code generator code template)
(from redmine: issue id 2228, created on 2015-01-23, closed on 2016-01-18)