/**
* Add the ConnectionInitialization to the diagram.
*/
public PictogramElement add(IAddContext context) {
LocalVariableStatement addedVar =
(LocalVariableStatement) context.getNewObject();
Diagram targetDiagram = (Diagram) context.getTargetContainer();
// CONTAINER SHAPE WITH ROUNDED RECTANGLE
IPeCreateService peCreateService = Graphiti.getPeCreateService();
ContainerShape containerShape =
peCreateService.createContainerShape(targetDiagram, true);
// check whether the context has a size (e.g. from a create feature)
// otherwise define a default size for the shape
int width = context.getWidth() <= 0 ? 200 : context.getWidth();
int height = context.getHeight() <= 0 ? 44 : context.getHeight();
IGaService gaService = Graphiti.getGaService();
{
// create and set graphics algorithm
RoundedRectangle roundedRectangle =
gaService.createRoundedRectangle(containerShape, 5, 5);
roundedRectangle.setStyle(StyleUtil.getStyleForCI(getDiagram()));
gaService.setLocationAndSize(roundedRectangle,
context.getX(), context.getY(), width, height);
//Don't think this should happen, but want to be sure
if (addedVar.eResource() == null) {
Activator.logInfo("ConnectionInitialization has no resource");
}
// create link and wire it
link(containerShape, addedVar);
}
//Check for child literal
Object lit = Utility.getChildLiteral(addedVar.getVariable(
).getInitialValue());
if (lit != null) {
AddContext addLiteralContext = new AddContext(
new AreaContext(), lit);
addLiteralContext.setTargetContainer(containerShape);