Shape element = (Shape) context.getProperty("org.activiti.designer.changetype.pictogram");
GraphicsAlgorithm elementGraphics = element.getGraphicsAlgorithm();
int x = elementGraphics.getX();
int y = elementGraphics.getY();
CreateContext taskContext = new CreateContext();
ContainerShape targetContainer = (ContainerShape) element.getContainer();
taskContext.setTargetContainer(targetContainer);
taskContext.setLocation(x, y);
taskContext.setHeight(elementGraphics.getHeight());
taskContext.setWidth(elementGraphics.getWidth());
FlowNode oldObject = (FlowNode) getFeatureProvider().getBusinessObjectForPictogramElement(element);
if (oldObject instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) oldObject;
ContainerShape parentShape = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(boundaryEvent.getAttachedToRef());
taskContext.setTargetContainer(parentShape);
taskContext.setLocation(x - parentShape.getGraphicsAlgorithm().getX(), y - parentShape.getGraphicsAlgorithm().getY());
}
List<SequenceFlow> sourceList = oldObject.getOutgoingFlows();
List<SequenceFlow> targetList = oldObject.getIncomingFlows();
taskContext.putProperty("org.activiti.designer.changetype.sourceflows", sourceList);
taskContext.putProperty("org.activiti.designer.changetype.targetflows", targetList);
taskContext.putProperty("org.activiti.designer.changetype.name", oldObject.getName());
targetContainer.getChildren().remove(element);
List<Process> processes = ModelHandler.getModel(EcoreUtil.getURI(getDiagram())).getBpmnModel().getProcesses();
for (Process process : processes) {
process.removeFlowElement(oldObject.getId());