@Override
public boolean update(IUpdateContext context) {
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
Participant participant = (Participant) BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(),
Participant.class);
ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
if (participant.getParticipantMultiplicity() != null) {
Shape shape = peService.createShape(containerShape, false);
peService.setPropertyValue(shape, MULTIPLICITY_MARKER, Boolean.toString(true));
Rectangle invisibleRectangle = gaService.createInvisibleRectangle(shape);
GraphicsAlgorithm parentGa = containerShape.getGraphicsAlgorithm();
int x = (parentGa.getWidth() / 2) - 10;
int y = parentGa.getHeight() - 20;
gaService.setLocationAndSize(invisibleRectangle, x, y, 20, 20);
Polyline line1 = gaService.createPolyline(invisibleRectangle, new int[] { 0, 0, 0, 20 });
line1.setLineWidth(2);
line1.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
Polyline line2 = gaService.createPolyline(invisibleRectangle, new int[] { 9, 0, 9, 20 });
line2.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
line2.setLineWidth(2);
Polyline line3 = gaService.createPolyline(invisibleRectangle, new int[] { 18, 0, 18, 20 });
line3.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
line3.setLineWidth(2);
} else {
Shape shape = FeatureSupport.getShape(containerShape, MULTIPLICITY_MARKER, Boolean.toString(true));
if (shape != null) {
peService.deletePictogramElement(shape);
}
}
peService.setPropertyValue(containerShape, AddParticipantFeature.MULTIPLICITY,
participant.getParticipantMultiplicity() != null ? Boolean.toString(true) : Boolean.toString(false));
return true;
}