Java Reference
In-Depth Information
protected void createEditPolicies(){
super .createEditPolicies();
installEditPolicy(EditPolicy.NODE_ROLE, null );
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null );
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null );
installEditPolicy(EditPolicy.COMPONENT_ROLE, new
RootComponentEditPolicy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, new
LogicXYLayoutEditPolicy(
(XYLayout)getContentPane().getLayoutManager()));
installEditPolicy(“Snap Feedback”, new SnapFeedbackPolicy());
}
9.2.4 The EditPart Life Cycle
As mentioned already, an EditPart begins its life when an EditPartFactory
creates it. Specifically, it begins when the EditPartViewer.setContents()
method is invoked; in the case of AbstractEditPartViewer , it calls the fac-
tory's createEditPart() method on the contents EditPart , which then cre-
ates all children EditPart s. The factory sets the EditPart 's model by calling
setModel() before the EditPart is returned.
When examining the life cycle of an EditPart , the AbstractEditPart.
addChild() method provides much of the story:
protected void addChild(EditPart child, int index) {
Assert.isNotNull(child);
if (index == -1) {
index = getChildren().size();
if (children == null )
children = new ArrayList(2);
children.add(index, child);
child.setParent( this );
addChildVisual(child, index);
child.addNotify();
if (isActive())
child.activate();
fireChildAdded(child, index);
}
Adding an EditPart to a Diagram
When EditPart children are created, or whenever the addChild() method is
invoked on the AbstractEditPart class, the setParent() method is called
Search WWH ::




Custom Search