// 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 ? 180 : context.getWidth();
int height = context.getHeight() <= 0 ? 24 : context.getHeight();
IGaService gaService = Graphiti.getGaService();
{
// create and set graphics algorithm
RoundedRectangle roundedRectangle =
gaService.createRoundedRectangle(containerShape, 5, 5);
roundedRectangle.setStyle(StyleUtil.getStyleForLiteral(getDiagram()));
gaService.setLocationAndSize(roundedRectangle,
context.getX() + 10, context.getY() + 10, width, height);
//Don't think this should happen, but want to check
if (addedObj.eResource() == null) {
Activator.logInfo("Literal has no resource");
}
// create link and wire it
link(containerShape, addedObj);
}
// SHAPE WITH TEXT
{
// create shape for text
Shape shape = peCreateService.createShape(containerShape, false);
// create and set text graphics algorithm
MultiText text = gaService.createDefaultMultiText(
getDiagram(), shape, Utility.getLiteralValue(addedObj));
text.setStyle(StyleUtil.getStyleForText(getDiagram()));
text.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
gaService.setLocationAndSize(text, 0, 0, width, 20);
// create link and wire it
link(shape, addedObj);
}
return containerShape;