}
protected void deleteBusinessObject(Object bo) {
if (bo instanceof Lane) {
Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
Lane lane = (Lane) bo;
Pool parentPool = null;
for (Pool pool : model.getBpmnModel().getPools()) {
if(pool.getProcessRef().equalsIgnoreCase(lane.getParentProcess().getId())) {
parentPool = pool;
break;
}
}
Process laneProcess = model.getBpmnModel().getProcess(parentPool.getId());
if (parentPool == null || laneProcess == null) return;
if(laneProcess.getLanes().size() == 1) {
Process process = model.getBpmnModel().getProcess(parentPool.getId());
model.getBpmnModel().getProcesses().remove(process);
model.getBpmnModel().getPools().remove(parentPool);
PictogramElement poolElement = getFeatureProvider().getPictogramElementForBusinessObject(parentPool);
IRemoveContext poolRc = new RemoveContext(poolElement);
IRemoveFeature poolRemoveFeature = getFeatureProvider().getRemoveFeature(poolRc);
if (poolRemoveFeature != null) {
poolRemoveFeature.remove(poolRc);
}
} else {
Shape poolShape = (Shape) getFeatureProvider().getPictogramElementForBusinessObject(parentPool);
ResizeShapeContext resizeContext = new ResizeShapeContext(poolShape);
resizeContext.setSize(poolShape.getGraphicsAlgorithm().getWidth(), poolShape.getGraphicsAlgorithm().getHeight() - laneHeight);
resizeContext.setLocation(poolShape.getGraphicsAlgorithm().getX(), poolShape.getGraphicsAlgorithm().getY());
resizeContext.setDirection(ResizeShapeContext.DIRECTION_NORTH);
resizeContext.putProperty("org.activiti.designer.lane.create", true);
getFeatureProvider().getResizeShapeFeature(resizeContext).execute(resizeContext);
}
for (Lane otherLane : lane.getParentProcess().getLanes()) {
if(otherLane.equals(lane)) continue;
Shape otherLaneShape = (Shape) getFeatureProvider().getPictogramElementForBusinessObject(otherLane);
if(otherLaneShape.getGraphicsAlgorithm().getY() > laneY) {
otherLaneShape.getGraphicsAlgorithm().setY(otherLaneShape.getGraphicsAlgorithm().getY() - laneHeight);
}
}
List<FlowElement> toDeleteElements = new ArrayList<FlowElement>();
for (String flowRef : lane.getFlowReferences()) {
for (FlowElement flowElement : lane.getParentProcess().getFlowElements()) {
if(flowRef.equalsIgnoreCase(flowElement.getId())) {
toDeleteElements.add(flowElement);
}
}
}
for (FlowElement subFlowElement : toDeleteElements) {
if(subFlowElement instanceof FlowNode) {
deleteSequenceFlows((FlowNode) subFlowElement);
}
removeElement(subFlowElement);
}
lane.getParentProcess().getLanes().remove(lane);
}
}