Java Reference
In-Depth Information
Another factor to consider with the enumeration approach is to map a sin-
gle archetype node and hand-code changes in color based on enumeration value
changes. This would greatly reduce the amount of generated code, but it leaves
us wondering how often users would want to change an archetype type. If they
did, the constraints and other factors we attribute to the archetype would have
to change, potentially causing a ripple effect on connections and more. With the
enumeration approach, to prevent users from changing the type, we could make
the type attribute read-only in our EMF genmodel . In our case the domain model
has a specific subclass for each archetype, making mapping straightforward and
eliminating the need to provide feature initialization for each mapping.
Furthermore, the generated code is much easier to deal with when using distinct
subtypes for each archetype. As you'll see, they generate EditPart names such
as MomentIntervalEditPart instead of a series of ArchetypeEditPart ,
Archetype2EditPart , and so on, as is the case when using enumeration liter-
als to distinguish type. We saw this in our Mindmap diagram when the
Relationship class used an enumeration to distinguish among dependency,
include, and extend types.
4.6.1 Diagram Definition
Unlike the previous diagram-definition models that referenced the domain model
when creating a graphical definition, we can simply create a blank dnc.
gmfgraph model in our /diagrams folder of the org.eclipse.dsl.dnc proj-
ect by skipping the pages in the Graphical Definition Wizard that select a model.
As mentioned earlier, we can define a single archetype figure and node to be
used for each of the mappings. Our archetype figures will use compartments for
attributes and operations. Coloration and gradients will be accomplished using
custom templates. Let's start with our archetype definition, shown in Table 4-32.
Table 4-32
Archetype Figure Definition
Element
Property
Value
Figure Gallery
Name
DNC Figures
Figure Descriptor
Name
ArchetypeFigure
Rounded Rectangle
Name
ArchetypeFigure
Insets
Bottom
5
Search WWH ::




Custom Search