From 12e989261434794d69c32fde2c18a744103dda16 Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 13 Nov 2013 11:51:49 +0000 Subject: [PATCH] Sysdyn scl update refs #3511 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28249 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.sysdyn/plugin.xml | 2 +- org.simantics.sysdyn/scl/Sysdyn.scl | 7 ++++-- .../sysdyn/utils/DocumentationUtils.java | 20 +++++++++++++++++ .../simantics/sysdyn/utils/ModelUtils.java | 22 ++++++++++++------- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/org.simantics.sysdyn/plugin.xml b/org.simantics.sysdyn/plugin.xml index 711fcb7e..e3c4447c 100644 --- a/org.simantics.sysdyn/plugin.xml +++ b/org.simantics.sysdyn/plugin.xml @@ -18,7 +18,7 @@ diff --git a/org.simantics.sysdyn/scl/Sysdyn.scl b/org.simantics.sysdyn/scl/Sysdyn.scl index fb63e325..21010c10 100644 --- a/org.simantics.sysdyn/scl/Sysdyn.scl +++ b/org.simantics.sysdyn/scl/Sysdyn.scl @@ -1,5 +1,5 @@ -include "http://www.simantics.org/DB" -include "http://www.simantics.org/Variables" +include "Simantics/DB" +include "Simantics/Variables" importJava "org.simantics.sysdyn.utils.DocumentationUtils" where @@ -85,4 +85,7 @@ importJava "org.simantics.sysdyn.utils.DocumentationUtils" where @JavaName importModel importModel :: String -> () + + @JavaName isParameter + isParameter :: Variable -> Boolean \ No newline at end of file diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java index b6d0190c..76431cc8 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java @@ -13,6 +13,7 @@ import org.simantics.databoard.util.Base64; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithSupertype; +import org.simantics.db.common.utils.ListUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; @@ -472,4 +473,23 @@ public class DocumentationUtils { ImportUtils.importModelFile(path, new NullProgressMonitor()); } + public static boolean isParameter(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable) throws DatabaseException { + SysdynResource SR = SysdynResource.getInstance(graph); + Resource represents = variable.getPossibleRepresents(graph); + System.out.println(graph.getURI(represents)); + if(represents == null || !graph.isInstanceOf(represents, SR.IndependentVariable)) + return false; + + Resource expressionList = graph.getPossibleObject(represents, SR.Variable_expressionList); + + if(expressionList == null) + return false; + + List expressions = ListUtils.toList(graph, expressionList); + if(expressions == null || expressions.size() != 1) + return false; + + Resource expression = expressions.get(0); + return graph.isInstanceOf(expression, SR.ParameterExpression); + } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java index ac88d5be..2d411193 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/ModelUtils.java @@ -54,7 +54,7 @@ public class ModelUtils { createModelAt(graph, Simantics.getProject().get()); } - public static void createModelAt(WriteGraph g, Resource library) { + public static Resource createModelAt(WriteGraph g, Resource library) { try { Layer0 l0 = Layer0.getInstance(g); Layer0X L0X = Layer0X.getInstance(g); @@ -168,10 +168,13 @@ public class ModelUtils { ProfileEntries.createStandardProfiles(g, model); + return model; } catch (DatabaseException e ) { Logger.defaultLogError(e); } + + return null; } public static void createSCLMain(WriteGraph graph, Resource model) throws DatabaseException { @@ -181,15 +184,18 @@ public class ModelUtils { L0.PartOf, model, L0.HasName, "SCLMain" ); - + if(graph.hasStatement(SCLModule, L0.SCLModule_definition)) graph.deny(SCLModule, L0.SCLModule_definition); - graph.claimLiteral(SCLModule, L0.SCLModule_definition, - "include \"Simantics/DB\"\n" + - "include \"Simantics/Variables\"\n" + - "include \"Simantics/Sysdyn\" as SD\n" + - "include \"http://www.simantics.org/Documentation-1.2/Components\"\n" + + + graph.claimLiteral(SCLModule, L0.SCLModule_definition, "include \"Simantics/DB\"\n" + + "include \"Simantics/Variables\"\n" + + "include \"Simantics/Sysdyn\"\n" + + "include \"Simupedia/Sysdyn\" as SD\n" + + "include \"http://www.simantics.org/Documentation-1.2/Components\"\n" + "include \"http://www.simantics.org/Documentation-1.2/Properties\" as Properties\n" + - "include \"http://www.simantics.org/Documentation-1.2/Relations\" as Relations", Bindings.STRING); + "include \"http://www.simantics.org/Documentation-1.2/Relations\" as Relations\n" + + "include \"Simupedia/simupedia\"", Bindings.STRING); + } } -- 2.47.1