{
// Source and target socket determined
if (sourceSocketFigure.canConnect() && targetSocketFigure.canConnect())
{
// Make sure the socket can connect and don't belong to the same node
FlowConnection connection = new FlowConnection(modeler.getDrawing());
if (connection.canConnectFigures(sourceSocketFigure, targetSocketFigure, 0) && sourceSocketFigure.getNodeSocket().getNode() != targetSocketFigure.getNodeSocket().getNode())
{
// We have two connection points.
modeler.startUndo("Auto-connect sockets");
connection.connectStart(sourceSocketFigure.connectorAt(0, 0));
connection.connectEnd(targetSocketFigure.connectorAt(0, 0));
modeler.getDrawing().add(connection);
connection.layoutAndAdjustConnection();
modeler.endUndo();
autoAdjustPlaceholderName();