Java Reference
In-Depth Information
set in your domain model are important to how a new element is initially dis-
played on the diagram. Without specifying default values for the lower- and
upper-bound properties, our label displays “[null,null]” and is not very user-
friendly.
TIP
In the mapping model, order matters.This is obvious in feature initializers,
but it might not be obvious in the case of node labels. For example, if a
node has two labels, the top of which is read-only (for example, with a
stereotype label), the default generated code does not allow the second
label (for example, the node's name) to be activated with the in-place edi-
tor when the node is created on the diagram. So reverse the order of the
label mappings to achieve the desired effect.
References, Containment, and Phantom Nodes
We've taken a look at how to map nodes to containment references using Top
Level and Child Node elements in our mapping model. If your domain model
has a straightforward mapping to a graphical display, particularly with respect
to containment versus noncontainment references, you will have no problems.
However, if you want to create a node on the diagram surface (a Top Level
Node ) but the domain element it represents is not a contained element of the ele-
ment used for the Canvas , you can see a problem. How do we indicate where to
store the created element represented by this node in the domain model instance?
We need to provide a link from this node to the element representing the
domain element that has the containment reference for objects of this type. The
problem is, we typically create nodes and then link them to other elements using
a link tool. So for a short period of time, we have a so-called “phantom” element
represented on our diagram surface that does not yet have a home. If you look
at your domain model instance after creating this type of node, you'll see that the
underlying domain element instance is held in the root of the model—that is,
until it is connected with a link to the contained element. The solution in this case
is to leave the Containment Feature property of the node mapping blank and
indicate the containment feature as the Target Feature of the corresponding
Link Mapping . Figure 11-10 is an example of our requirements model and its
Link Mapping for Requirement children.
 
Search WWH ::




Custom Search