@Override
protected void postMoveShape(IMoveShapeContext context) {
final Shape shape = context.getShape();
// get the event itself to determine its boundary events
final Event event = (Event) getBusinessObjectForPictogramElement(shape);
Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
if (context.getSourceContainer() != context.getTargetContainer()) {
if (context.getSourceContainer() instanceof Diagram == false) {
Object containerBo = getFeatureProvider().getBusinessObjectForPictogramElement(context.getSourceContainer());
if (containerBo instanceof SubProcess) {
SubProcess subProcess = (SubProcess) containerBo;
subProcess.removeFlowElement(event.getId());
for (SequenceFlow flow : event.getOutgoingFlows()) {
subProcess.removeFlowElement(flow.getId());
}
} else if (containerBo instanceof Lane) {
Lane lane = (Lane) containerBo;
lane.getFlowReferences().remove(event.getId());
lane.getParentProcess().removeFlowElement(event.getId());
for (SequenceFlow flow : event.getOutgoingFlows()) {
lane.getParentProcess().removeFlowElement(flow.getId());
}
}
} else {
model.getBpmnModel().getMainProcess().removeFlowElement(event.getId());
for (SequenceFlow flow : event.getOutgoingFlows()) {
model.getBpmnModel().getMainProcess().removeFlowElement(flow.getId());
}
}
if (context.getTargetContainer() instanceof Diagram == false) {
Object containerBo = getFeatureProvider().getBusinessObjectForPictogramElement(context.getTargetContainer());
if (containerBo instanceof SubProcess) {
SubProcess subProcess = (SubProcess) containerBo;
subProcess.addFlowElement(event);
for (SequenceFlow flow : event.getOutgoingFlows()) {
subProcess.addFlowElement(flow);
}
} else if (containerBo instanceof Lane) {
Lane lane = (Lane) containerBo;
lane.getFlowReferences().add(event.getId());
lane.getParentProcess().addFlowElement(event);
for (SequenceFlow flow : event.getOutgoingFlows()) {
lane.getParentProcess().addFlowElement(flow);
}
}
} else {
model.getBpmnModel().getMainProcess().addFlowElement(event);
for (SequenceFlow flow : event.getOutgoingFlows()) {
model.getBpmnModel().getMainProcess().addFlowElement(flow);
}
}
}
}