Java Reference
In-Depth Information
resource set using the
Runtime Version
, and we create a new reference to our
ToolTip
class named
textAttribute
of type
EAttribute
.
In our
requirements.gmfgen
model, navigate to the
Gen Top Level
Node RequirementEditPart
element and add a new child
Custom Behaviour
element. It's a simple element, with just
Key
and
Edit Policy Qualified
Class Name
properties, which we set to
"TooltipPolicy"
(the quotation
marks are required) and
org.eclipse.requirements.diagram.edit.
policies.RequirementsTooltipEditPolicy
, respectively. The parameter
used to install an
EditPolicy
is a String, which typically comes from constants
defined in either the GMF runtime's
EditPolicyRoles
interface or GEF's
EditPolicy
interface. Look at the policy roles defined here before you create
your own. If you reuse a defined constant, you don't need to wrap it in quotes.
Next, we need to create a Dynamic Instance of our ToolTip model for use in
generating our custom
EditPolicy
. This is much more convenient than the
alternative, which is to create a
tooltip.gen
model and generate model code,
followed by deploying that model into the environment. From the Ecore editor,
we right-click our
Tooltip
element and select
Create Dynamic Instance
and
select our
/diagrams
folder for the new
Tooltip.xmi
model. In the
Sample
Reflective Ecore Model Editor
, use Load Resource to load our
requirements.
genmodel
from the workspace. Now we can select the
Custom Behaviour
ele-
ment that we added previously for our
Editpolicy
property. This is where the
option of using the
Runtime Version
in our loading of the GMF GenModel
earlier becomes important, for if we left the reference as
platform:/plugin
...,
we would not have seen our
Custom Behaviour
element in the list.
Finally, set the
textAttribute
property of our
Tooltip
instance to the
title:EString
attribute of our Requirements class, which was loaded into the
resource set when we loaded the
requirements.gmfgen
model.
TIP
When selecting the
title:EString
attribute for our
textAttribute
reference, we had to select it from a large list of possibilities in the
Properties view, several of which had the required
name:Type
but with
no indication that it was from our Requirements class. First, to narrow the
list, type
title
into the field to filter the possibilities. Second, verify that
the proper element was selected by opening the model in a text editor.
Search WWH ::
Custom Search