From: lempinen Date: Mon, 2 Aug 2010 06:05:05 +0000 (+0000) Subject: Fix for updated modelingrules X-Git-Tag: simantics-1.2.0~144 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=847486a6bc032935d6e04b2a71d261f9651c846b;p=simantics%2Fsysdyn.git Fix for updated modelingrules git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16892 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynConnectionAdvisor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynConnectionAdvisor.java index bcf57825..e289eddf 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynConnectionAdvisor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynConnectionAdvisor.java @@ -1,5 +1,8 @@ package org.simantics.sysdyn.ui.editor; +import java.util.ArrayList; +import java.util.Arrays; + import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; @@ -15,7 +18,8 @@ import org.simantics.g2d.element.IElement; import org.simantics.g2d.elementclass.FlagHandler; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.structural2.modelingRules.CPFlag; -import org.simantics.structural2.modelingRules.IConnection; +import org.simantics.structural2.modelingRules.ConnectionJudgement; +import org.simantics.structural2.modelingRules.ConnectionJudgementType; import org.simantics.structural2.modelingRules.IConnectionPoint; import org.simantics.structural2.modelingRules.IModelingRules; import org.simantics.sysdyn.SysdynResource; @@ -80,12 +84,15 @@ public class SysdynConnectionAdvisor implements IConnectionAdvisor { } } - IConnection connection = modelingRules.createConnection() - .attachNew(g, getConnectionPoint(g, element1, term1)); + ArrayList cps = new ArrayList(); + cps.add(getConnectionPoint(g, element1, term1)); if(element2 != null) - connection = connection.attachNew(g, getConnectionPoint(g, element2, term2)); - if(connection.isLegal()) - return connection.getConnectionType(); + cps.add(getConnectionPoint(g, element2, term2)); + ConnectionJudgement judgement = + modelingRules.judgeConnection(g, cps); + + if(judgement.type == ConnectionJudgementType.LEGAL) + return judgement.connectionType; else return null; } @@ -107,9 +114,9 @@ public class SysdynConnectionAdvisor implements IConnectionAdvisor { @Override public Boolean perform(ReadGraph g) throws DatabaseException { - return modelingRules.createConnection() - .attachNew(g, getConnectionPoint(g, element, term)) - .isLegal(); + return modelingRules.judgeConnection(g, + Arrays.asList(getConnectionPoint(g, element, term))) + .type != ConnectionJudgementType.ILLEGAL; } });