public PictogramElement add(IAddContext context) {
final ContainerShape targetContainer = (ContainerShape) context
.getTargetContainer();
Partecipant partecipant = (Partecipant) getBusinessObjectForPictogramElement(targetContainer);
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final ContainerShape containerShape = peCreateService
.createContainerShape(targetContainer, true);
...CODE...
{
rectangle = gaService.createPlainRectangle(containerShape);
gaService.setLocationAndSize(rectangle, context.getX(),
context.getY(), width, height);
rectangle
.setBackground(manageColor(IColorConstant.LIGHT_LIGHT_GRAY));
rectangle.setForeground(manageColor(IColorConstant.GRAY));
link(containerShape,partecipant);
}
// add a chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
return containerShape;
}
public Connection create(ICreateConnectionContext context) {
Connection newConnection = null;
Object source = getObject(context.getSourceAnchor());
Object target = getObject(context.getTargetAnchor());
if (source != null && target != null) {
// create new business object
Message_RR message = PassiseqdiagFactory.eINSTANCE
.createMessage_RR();
message.setMessage_RRSource((Role) source);
message.setMessage_RRTarget((Role) target);
message.setContent(content);
((Role) source).getList_RRMessagesOut().add(message);
((Role) target).getList_RRMessagesIn().add(message);
...CODE...
return newConnection;
}
private Object getObject(Anchor anchor) {
if (anchor != null) {
Object object = getBusinessObjectForPictogramElement(anchor
.getParent());
return object;
}
return null;
}