Java Reference
In-Depth Information
String text = ((Requirement) resolveSemanticElement()).getTitle();
Label tooltip = new Label(text);
tooltip.setBorder(new MarginBorder(getMapMode().DptoLP(0),
getMapMode().DptoLP(5), getMapMode().DptoLP(5),
getMapMode().DptoLP(5)));
figure.setToolTip(tooltip);
return figure;
}
This works but suffers from the fact that if the title attribute is modi-
fied, the ToolTip does not reflect the change. We could override
handleNotificationEvent() in our EditPart and update the ToolTip
when changes are made, but a better solution is to leverage a custom
EditPolicy . Furthermore, this is something we'll potentially need for our
RequirementsGroup because it is also a fixed-size shape that requires selection
and the Properties view currently to get the full text. Instead of continuing to
modify the generated code, this seems like a good opportunity to add a decora-
tor model to our requirements.gmfgen model to specify ToolTips and their
displayed attributes for selected elements. We begin by creating a simple
tooltip.ecore model in the /diagrams folder of our requirements project,
with just a root Model element that contains a collection of ToolTip elements,
which, in turn, contains a number of DisplayElement s. The important aspect
of the model is the reference from the ToolTip to the GMF generation model's
CustomBehaviour class, as shown in Figure 4-20 using a diagram shortcut.
Figure 4-20
ToolTip model
Search WWH ::




Custom Search