private Connection createConnectionAndSetBendpoints(BPMNEdge bpmnEdge, PictogramElement sourceElement,
PictogramElement targetElement) {
FixPointAnchor sourceAnchor = createAnchor(sourceElement);
FixPointAnchor targetAnchor = createAnchor(targetElement);
AddConnectionContext context = new AddConnectionContext(sourceAnchor, targetAnchor);
context.setNewObject(bpmnEdge.getBpmnElement());
IAddFeature addFeature = featureProvider.getAddFeature(context);
if (addFeature != null && addFeature.canAdd(context)) {
context.putProperty(IMPORT_PROPERTY, true);
Connection connection = (Connection) addFeature.add(context);
if (connection instanceof FreeFormConnectionImpl) {
FreeFormConnectionImpl freeForm = (FreeFormConnectionImpl) connection;
List<Point> waypoint = bpmnEdge.getWaypoint();
int size = waypoint.size() - 1;
setAnchorLocation(sourceElement, sourceAnchor, waypoint.get(0));
setAnchorLocation(targetElement, targetAnchor, waypoint.get(size));
for (int i = 1; i < size; i++) {
DIUtils.addBendPoint(freeForm, waypoint.get(i));
}
}
featureProvider.link(connection, new Object[] { bpmnEdge.getBpmnElement(), bpmnEdge });
return connection;
} else {
Activator.logStatus(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Unsupported feature "
+ ((EObject) context.getNewObject()).eClass().getName()));
}
return null;
}