Java Reference
In-Depth Information
The getNodeEditPartClass() method is passed a View object that, in
turn, is passed to the getReferencedElementEClass() method of the super-
class. The View object's element EClass is resolved and returned for use in
retrieving the proper EditPart class from the shapeMap.
As you can see, we need to provide a TopicEditPart class. As usual, we
extend a class provided by the runtime that offers most of the functionality we
need. In this case, our TopicEditPart extends ShapeNodeEditPart and over-
rides createNodeFigure() to return a DefaultSizeNodeFigure with a
child RoundedRectangle to provide the main figure.
public class TopicEditPart extends ShapeNodeEditPart {
public TopicEditPart(View view) {
super (view);
}
@Override
protected NodeFigure createNodeFigure() {
final NodeFigure figure = new
DefaultSizeNodeFigure(getMapMode()
.DPtoLP(40), getMapMode().DPtoLP(40));
figure.setLayoutManager( new StackLayout());
figure.add( new TopicFigure());
return figure;
}
public class TopicFigure extends RoundedRectangle {
public TopicFigure() {
this .setCornerDimensions( new
Dimension(getMapMode().DPtoLP(10), getMapMode().DPtoLP(10)));
}
}
}
Continuing from the last section, when a new Topic domain element and
view are created, the diagram's EditPart receives the notification event and
refreshes its children. As a View notification event, there is not yet an EditPart
for the new domain element, so it invokes the EditPartFactory to create a
new one and add it to its list of children. As you can see from the earlier
TopicEditPart class, a new RoundedRectangle figure is created and dis-
played on the diagram.
New Diagram Wizard
To test our diagram, we need a wizard to create and initialize a new diagram
editor instance. First, we contribute to the org.eclipse.ui.newWizards
extension-point declaring a new MindmapDiagramCreationWizard that
Search WWH ::




Custom Search