@Override
public PictogramElement add(IAddContext context) {
PictogramElement pe = addFeatureDelegate.add(context);
// make sure everyone knows that this PE is a custom task
if (pe!=null)
Graphiti.getPeService().setPropertyValue(pe,CUSTOM_ELEMENT_ID,getId());
// add an icon to the top-left corner if applicable, and if the implementing
// addFeatureDelegate hasn't already done so.
String icon = customTaskDescriptor.getIcon();
if (icon!=null && pe instanceof ContainerShape) {
boolean addImage = true;
ContainerShape containerShape = (ContainerShape)pe;
GraphicsAlgorithm ga =
GraphicsAlgorithm)AbstractBpmn2AddFeature.getGraphicsAlgorithm(containerShape);
for (PictogramElement child : containerShape.getChildren()) {
if (child.getGraphicsAlgorithm() instanceof Image) {
addImage = false;
break;
}
}
if (ga!=null) {
for (GraphicsAlgorithm g : ga.getGraphicsAlgorithmChildren()) {
if (g instanceof Image) {
addImage = false;
break;
}
}
}
else
addImage = false;
if (addImage) {
Image img = CustomTaskImageProvider.createImage(customTaskDescriptor, ga, icon, 24, 24);
Graphiti.getGaService().setLocationAndSize(img, 2, 2, 24, 24);
}
}
return pe;
}