public boolean update(IUpdateContext context) {
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
ContainerShape container = (ContainerShape) context.getPictogramElement();
CallActivity callActivity = BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(),
CallActivity.class);
ContainerShape markerContainer = (ContainerShape) getShape(container,
GraphicsUtil.ACTIVITY_MARKER_CONTAINER);
Shape globalTaskShape = getShape(container, GLOBAL_TASK_SHAPE_PROPERTY);
if (callActivity.getCalledElementRef() == null) {
GraphicsUtil.clearActivityMarker(markerContainer, GraphicsUtil.ACTIVITY_MARKER_EXPAND);
if (globalTaskShape != null) {
peService.deletePictogramElement(globalTaskShape);
}
}
else if (callActivity.getCalledElementRef() instanceof GlobalTask) {
GraphicsUtil.clearActivityMarker(markerContainer, GraphicsUtil.ACTIVITY_MARKER_EXPAND);
GlobalTask t = (GlobalTask) callActivity.getCalledElementRef();
if (globalTaskShape == null) {
globalTaskShape = peService.createShape(container, false);
peService.setPropertyValue(globalTaskShape, GLOBAL_TASK_SHAPE_PROPERTY, Boolean.toString(true));
}
String imageId = getImageId(t);
if (imageId != null) {
Image image = gaService.createImage(globalTaskShape, imageId);
gaService.setLocationAndSize(image, MARKER_OFFSET + 2, MARKER_OFFSET + 2, 16, 16);
}
}
else if (callActivity.getCalledElementRef() instanceof Process) {
if (globalTaskShape != null) {
peService.deletePictogramElement(globalTaskShape);
}
Expand expand = GraphicsUtil.createActivityMarkerExpand(markerContainer);
expand.rect.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
expand.horizontal.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
expand.vertical.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
}
peService.setPropertyValue(container, CALL_ACTIITY_REF_PROPERTY,
getCallableElementStringValue(callActivity.getCalledElementRef()));
return true;
}