]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fix for updated modelingrules
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 2 Aug 2010 06:05:05 +0000 (06:05 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 2 Aug 2010 06:05:05 +0000 (06:05 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16892 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynConnectionAdvisor.java

index bcf578251bf44bd4e1dd29985511c5d86da4ad5e..e289eddffbc861103ce8ffde990d2727d05060c6 100644 (file)
@@ -1,5 +1,8 @@
 package org.simantics.sysdyn.ui.editor;\r
 \r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.RequestProcessor;\r
 import org.simantics.db.Resource;\r
@@ -15,7 +18,8 @@ import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.elementclass.FlagHandler;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.structural2.modelingRules.CPFlag;\r
-import org.simantics.structural2.modelingRules.IConnection;\r
+import org.simantics.structural2.modelingRules.ConnectionJudgement;\r
+import org.simantics.structural2.modelingRules.ConnectionJudgementType;\r
 import org.simantics.structural2.modelingRules.IConnectionPoint;\r
 import org.simantics.structural2.modelingRules.IModelingRules;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -80,12 +84,15 @@ public class SysdynConnectionAdvisor  implements IConnectionAdvisor {
                         }\r
                     }\r
 \r
-                    IConnection connection = modelingRules.createConnection()\r
-                    .attachNew(g, getConnectionPoint(g, element1, term1));\r
+                    ArrayList<IConnectionPoint> cps = new ArrayList<IConnectionPoint>();\r
+                    cps.add(getConnectionPoint(g, element1, term1));\r
                     if(element2 != null)\r
-                        connection = connection.attachNew(g, getConnectionPoint(g, element2, term2));\r
-                    if(connection.isLegal())\r
-                        return connection.getConnectionType();\r
+                        cps.add(getConnectionPoint(g, element2, term2));\r
+                    ConnectionJudgement judgement = \r
+                        modelingRules.judgeConnection(g, cps);                  \r
+                    \r
+                    if(judgement.type == ConnectionJudgementType.LEGAL)\r
+                        return judgement.connectionType;\r
                     else\r
                         return null;\r
                 }\r
@@ -107,9 +114,9 @@ public class SysdynConnectionAdvisor  implements IConnectionAdvisor {
 \r
                 @Override\r
                 public Boolean perform(ReadGraph g) throws DatabaseException {\r
-                    return modelingRules.createConnection()\r
-                    .attachNew(g, getConnectionPoint(g, element, term))\r
-                    .isLegal();\r
+                    return modelingRules.judgeConnection(g,\r
+                            Arrays.asList(getConnectionPoint(g, element, term)))\r
+                            .type != ConnectionJudgementType.ILLEGAL;\r
                 }\r
 \r
             });\r