From 4bdf4df7a0725b2df01b7ee51e0590ecedd297ed Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 8 Oct 2010 07:41:25 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18324 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/editor/participant/ConnectTool.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/ConnectTool.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/ConnectTool.java index 21ecd463..0f9198cc 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/ConnectTool.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/ConnectTool.java @@ -243,10 +243,7 @@ public class ConnectTool extends AbstractDiagramParticipant { // TODO: broken. connection = ghostDiagram.getMutatedCorrespondence(possibleConnection); } else { - Object connectionType = connection.getHint(ElementHints.KEY_CONNECTION_TYPE); connection = createConnection(connectionClass); - connection.setHint(ElementHints.KEY_CONNECTION_TYPE, connectionType); - ghostDiagram.addElement(connection); } @@ -261,12 +258,23 @@ public class ConnectTool extends AbstractDiagramParticipant { topology.connect(edge, EdgeEnd.Begin, firstElement, firstTerminal); if (endElement != null) { + IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR); + Object canConnect = canConnect(advisor, ghostDiagram.getMutatedCorrespondence(endElement), endTerminal); + if(canConnect != null) { + connection.setHint(ElementHints.KEY_CONNECTION_TYPE, canConnect); + } topology.connect(edge, EdgeEnd.End, ghostDiagram.getMutatedCorrespondence(endElement), endTerminal); } else { IElement secondElement = connectionHandler.newBranchPoint(connection); controlPoints.add(secondElement); ElementUtils.setPos(secondElement, pos); Terminal secondTerminal = ElementUtils.getSingleTerminal(secondElement); + IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR); + Object canConnect = canConnect(advisor, null, null); + if(canConnect != null) { + connection.setHint(ElementHints.KEY_CONNECTION_TYPE, canConnect); + } + topology.connect(edge, EdgeEnd.End, secondElement, secondTerminal); } DiagramUtils.validateAndFix(ghostDiagram, getContext()); @@ -457,13 +465,13 @@ public class ConnectTool extends AbstractDiagramParticipant { return true; } else { if (isCurrentConnectionFlow() && startElement != null && startTerminal != null) { - - createValveIfNecessary(mouseCanvasPos); - + IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR); Object canConnect = canConnect(advisor, null, null); if (canConnect != null) connection.setHint(ElementHints.KEY_CONNECTION_TYPE, canConnect); + + createValveIfNecessary(mouseCanvasPos); // Finish connection in thin air only if the // connection was started from a valid terminal. -- 2.47.1