Java Reference
In-Depth Information
Activation is the final step in the process of adding a new EditPart to a dia-
gram in which the EditPart observes changes in the model or supports editing.
For this, the EditPart.activate() method is invoked during creation and
can be invoked later following a call to deactivate() . The following occurs
during activate() :
1. The EditPart begins to observe its model. This is done by extending this
method and registering listeners on the model element.
2. The EditPart activates all its EditPolicies using the corresponding
activate() method.
3. The EditPart activates all its children.
4. The EditPart notifies its listeners that it is active.
5. The EditPart activates all its source ConnectionEditParts.
At this point, the EditPart is created and activated, ready for normal use;
it can be selected, provide feedback, respond to requests, return commands, and
so on. The EditPart is deactivated upon deletion of the element or disposal of
its viewer.
EditPart Disposal
To complement the activate() method, EditPart s provide a deactivate()
method. This method is also meant to be extended by your EditPart so that lis-
teners registered by activate() can be unregistered. Otherwise, deacti-
vate() undoes all that activate( ) did, by default.
Although deactivation is guaranteed to occur for viewer disposal, the fol-
lowing also takes place for model element deletion. Because addChild() was
responsible for creating and initializing an EditPart , the AbstractEditPart.
removeChild() method is responsible for the cleanup. This is its implementa-
tion, for reference:
protected void removeChild(EditPart child) {
Assert.isNotNull(child);
int index = getChildren().indexOf(child);
if (index < 0)
return;
fireRemovingChild(child, index);
if (isActive())
child.deactivate();
child.removeNotify();
removeChildVisual(child);
child.setParent( null );
getChildren().remove(child);
}
Search WWH ::




Custom Search