Java Reference
In-Depth Information
to establish the hierarchy of
EditPart
s. This is done so that an
EditPart
can
navigate this hierarchy, if required—for example, when it needs to obtain its
viewer to access its
EditPart
registry.
Along with setting the parent of an
EditPart
during
addChild()
, its
Figure
is created by a call to
addChildVisual()
. Actually, the default imple-
mentation in
AbstractGraphicalEditPart
calls
getFigure()
, which calls
the
createFigure()
method. Your
EditPart
must implement this abstract
method.
To refresh itself for the first time following its addition to the parent
EditPart
, the
addNotify()
method is invoked. The default behavior of
addNotify(
)
performs the following:
Registers its model in the
EditPartViewer
's
EditPart
registry so that
EditPart
s can find other
EditParts
.
❍
Registers its figure in the
EditPartViewer
's visual part registry (used for
hit testing).
❍
Registers the
EditPart
for accessibility, if applicable.
❍
Creates the EditPolicies it needs by invoking
createEditPolicies()
,
which is abstract and requires implementation by your
EditPart
. In
turn, the
EditPart.installEditPolicy()
method is invoked, passing
required EditPolicies and their role.
❍
Invokes
addNotify()
on its children and then invokes
refresh()
. The
default implementation of
refresh()
invokes
refreshVisuals()
and
refreshChildren()
. As you saw earlier in the
refreshVisuals()
implementation in
LogicEditPart
, this method is intended to be overrid-
den by your
EditPart
because the default implementation does nothing.
The
refreshChildren()
method is the opposite: The default implemen-
tation should not be overridden and can be computationally expensive.
Therefore, it should be invoked only when required. Following is the API
documentation, to provide more detail on this method and its use.
❍
The final act of
addNotify()
is to register the
EditPart
as the source
or target of connections using overridden
getSourceConnections()
and
getTargetConnections()
, respectively, as applicable.
❍
The
AbstractEditPart.refreshChildren()
method updates its child
EditPart
s so that they are in sync with their model elements. This method is
called from
refresh()
and can also be called upon notification from the model.
Take care when calling this method; it can be a performance hit. When possible,
call
removeChild(EditPart)
and
addChild(EditPart, int)
instead.
Search WWH ::
Custom Search