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(gateway.getId());
for (SequenceFlow flow : gateway.getOutgoingFlows()) {
subProcess.removeFlowElement(flow.getId());
}
} else if (containerBo instanceof Lane) {
Lane lane = (Lane) containerBo;
lane.getFlowReferences().remove(gateway.getId());
lane.getParentProcess().removeFlowElement(gateway.getId());
for (SequenceFlow flow : gateway.getOutgoingFlows()) {
lane.getParentProcess().removeFlowElement(flow.getId());
}
}
} else {
model.getBpmnModel().getMainProcess().removeFlowElement(gateway.getId());
for (SequenceFlow flow : gateway.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(gateway);
for (SequenceFlow flow : gateway.getOutgoingFlows()) {
subProcess.addFlowElement(flow);
}
} else if (containerBo instanceof Lane) {
Lane lane = (Lane) containerBo;
lane.getFlowReferences().add(gateway.getId());
lane.getParentProcess().addFlowElement(gateway);