private boolean modelValidate(Figure start, Figure end, ConnectionFigure conn, Figure newNode, boolean bChangeStart) {
if (start == null || end == null ||conn == null || newNode == null)
return false;
ModelValidation modelValidation = (ModelValidation)operationTool.getContext().getValue(GraphicalEditor.MODEL_VALIDATION);
if (modelValidation == null)
return true;
String startId = (String)start.getAttribute("id");//--constraintId
String endId = (String)end.getAttribute("id");//--featureId
String type = (String)conn.getAttribute("type");
String newNodeId = (String)newNode.getAttribute("id");
if (conn instanceof PLConnection) {
Connector connector = conn.getStartConnector();
if (connector == null) { //--change plConnection start
boolean bReturn = modelValidation.canChangeConnection(endId, startId, false, newNodeId, bChangeStart);
if (bReturn)
bReturn = modelValidation.canChangeConnection(endId, startId, true, newNodeId, bChangeStart);
return bReturn;
}
int nDirection = connector.getDirection();
if (nDirection == Connector.EAST_DIRECTION || nDirection == Connector.SOUTH_DIRECTION) //--sink
return modelValidation.canChangeConnection(endId, startId, false, newNodeId, bChangeStart);
else
return modelValidation.canChangeConnection(endId, startId, true, newNodeId, bChangeStart);
}
if (conn instanceof DecomposeConnection || conn instanceof AttributeConnection)
return modelValidation.canChangeConnection(startId, endId, newNodeId, bChangeStart, type);
return true;
}