Java Reference
In-Depth Information
public class ScenarioViewProvider extends AbstractViewProvider {
@Override
protected Class getNodeViewClass(IAdaptable semanticAdapter, View
containerView, String semanticHint) {
if (containerView == null ) {
return null ;
}
EObject semanticElement = getSemanticElement(semanticAdapter);
int nodeVID =
ScenarioVisualIDRegistry.getNodeVisualID(containerView,
semanticElement);
if (nodeVID == Event2EditPart.VISUAL_ID) {
return IntermediateEventImageViewFactory. class ;
}
return null ;
}
}
Technically, our ViewFactory is not required right now, but later we can
override the decorateView() method to add custom style information. For
now, simply create this class in a *. custom.factories package and extend the
generated Event2ViewFactory class.
Our new ScenarioEditPartProvider class follows, with its override of
method getNodeEditPartClass() . If the passed View 's domain model ele-
ment is an instance of Event and its type is INTERMEDIATE , we return our
IntermediateEventImageEditPart class.
public class ScenarioEditPartProvider extends AbstractEditPartProvider {
@Override
protected Class getNodeEditPartClass(View view) {
if (view.getElement() instanceof Event && ((Event)
view.getElement()).getEventType().getValue() ==
EventType.INTERMEDIATE_VALUE) {
return IntermediateEventImageEditPart. class ;
}
return super .getNodeEditPartClass(view);
}
}
Our new EditPart class extends our Event2EditPart original and over-
rides the createNodeShape() method. As you can see here, an ievent.svg
file is used to represent our intermediate event node, and it is located in an
/images folder. Following is the EditPart code, followed by the ievent.svg
Search WWH ::




Custom Search