]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18324 ac1ea38d-2e2b... simantics-1.2.0
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Oct 2010 07:41:25 +0000 (07:41 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Oct 2010 07:41:25 +0000 (07:41 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/ConnectTool.java

index 21ecd463512cc857b6aba0a9d1f9a8efaec39f03..0f9198cc6d261c4a515b286354b44b9b32838f9d 100644 (file)
@@ -243,10 +243,7 @@ public class ConnectTool extends AbstractDiagramParticipant {
                        // TODO: broken.\r
                        connection = ghostDiagram.getMutatedCorrespondence(possibleConnection);\r
                } else {\r
-                       Object connectionType = connection.getHint(ElementHints.KEY_CONNECTION_TYPE);\r
                        connection = createConnection(connectionClass);\r
-                       connection.setHint(ElementHints.KEY_CONNECTION_TYPE, connectionType);\r
-                       \r
                        ghostDiagram.addElement(connection);\r
                }\r
 \r
@@ -261,12 +258,23 @@ public class ConnectTool extends AbstractDiagramParticipant {
                topology.connect(edge, EdgeEnd.Begin, firstElement, firstTerminal);\r
                \r
                if (endElement != null) {\r
+                       IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR);\r
+                       Object canConnect = canConnect(advisor, ghostDiagram.getMutatedCorrespondence(endElement), endTerminal);\r
+                       if(canConnect != null) {\r
+                               connection.setHint(ElementHints.KEY_CONNECTION_TYPE, canConnect);\r
+                       }\r
                        topology.connect(edge, EdgeEnd.End, ghostDiagram.getMutatedCorrespondence(endElement), endTerminal);\r
                } else {\r
                        IElement secondElement = connectionHandler.newBranchPoint(connection);\r
                        controlPoints.add(secondElement);\r
                        ElementUtils.setPos(secondElement, pos);\r
                        Terminal secondTerminal = ElementUtils.getSingleTerminal(secondElement);\r
+                       IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR);\r
+                       Object canConnect = canConnect(advisor, null, null);\r
+                       if(canConnect != null) {\r
+                               connection.setHint(ElementHints.KEY_CONNECTION_TYPE, canConnect);\r
+                       }\r
+                       \r
                        topology.connect(edge, EdgeEnd.End, secondElement, secondTerminal);\r
                }\r
                DiagramUtils.validateAndFix(ghostDiagram, getContext());\r
@@ -457,13 +465,13 @@ public class ConnectTool extends AbstractDiagramParticipant {
                                        return true;\r
                                }  else {\r
                                        if (isCurrentConnectionFlow() && startElement != null && startTerminal != null) {\r
-\r
-                                               createValveIfNecessary(mouseCanvasPos);\r
-\r
+                                               \r
                                                IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR);\r
                                                Object canConnect = canConnect(advisor, null, null);\r
                                                if (canConnect != null)\r
                                                        connection.setHint(ElementHints.KEY_CONNECTION_TYPE, canConnect);\r
+                                               \r
+                                               createValveIfNecessary(mouseCanvasPos);\r
 \r
                                                // Finish connection in thin air only if the\r
                                                // connection was started from a valid terminal.\r