super(fp);
}
@Override
public void postReconnect(IReconnectionContext context) {
Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
Object connectionObject = getFeatureProvider().getBusinessObjectForPictogramElement(context.getConnection());
if(connectionObject instanceof SequenceFlow == false) return;
SequenceFlow flow = (SequenceFlow) connectionObject;
Object targetObject = getFeatureProvider().getBusinessObjectForPictogramElement(context.getTargetPictogramElement());
if(targetObject instanceof FlowNode == false) return;
FlowNode targetElement = (FlowNode) targetObject;
if(ReconnectionContext.RECONNECT_TARGET.equalsIgnoreCase(context.getReconnectType())) {
List<SequenceFlow> flowList = targetElement.getIncomingFlows();
boolean found = false;
for (SequenceFlow sequenceFlow : flowList) {
if(sequenceFlow.getId().equals(flow.getId())) {
found = true;
}
}
if(found == false) {
FlowNode targetFlowNode = (FlowNode) model.getBpmnModel().getFlowElement(flow.getTargetRef());
if (targetFlowNode != null) {
// remove old target
targetFlowNode.getIncomingFlows().remove(flow);
}
targetElement.getIncomingFlows().add(flow);
flow.setTargetRef(targetElement.getId());
}
} else if(ReconnectionContext.RECONNECT_SOURCE.equalsIgnoreCase(context.getReconnectType())) {
// targetElement is the source side of the sequence flow
List<SequenceFlow> flowList = targetElement.getOutgoingFlows();
boolean found = false;
for (SequenceFlow sequenceFlow : flowList) {
if(sequenceFlow.equals(flow)) {
found = true;
}
}
if(found == false) {
FlowNode sourceFlowNode = (FlowNode) model.getBpmnModel().getFlowElement(flow.getSourceRef());
ContainerShape sourceElement = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(sourceFlowNode);
ContainerShape oldParentContainer = sourceElement.getContainer();
ContainerShape newParentContainer = ((ContainerShape) context.getTargetPictogramElement()).getContainer();
if (oldParentContainer != newParentContainer) {