2 include "Simantics/Variables"
3 include "Simantics/Ontologies"
5 include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery
7 importJava "org.simantics.scl.compiler.errors.CompilationError" where
10 importJava "org.simantics.scl.ui.editor.TextAndErrors" where
12 createTextAndErrors :: String -> [CompilationError] -> TextAndErrors
14 createSCLModuleAction :: Resource -> <Proc> ()
15 createSCLModuleAction res = ignore $ syncWrite (\() -> createSCLModuleDefault res)
17 createSCLScriptAction :: Resource -> <Proc> ()
18 createSCLScriptAction res = ignore $ syncWrite (\() -> createSCLScriptDefault res)
20 createPGraphAction :: Resource -> <Proc> ()
21 createPGraphAction res = ignore $ syncWrite (\() -> createPGraphDefault res)
23 createSCLValueIndependent :: Resource -> String -> <WriteGraph> Resource
24 createSCLValueIndependent valueType expression = do
25 value = newResource ()
26 claim value L0.InstanceOf valueType
27 claimRelatedValue value L0.SCLValue.expression expression
30 createSCLValue :: Resource -> Resource -> Resource -> String -> <WriteGraph> Resource
31 createSCLValue container predicate valueType expression = do
32 value = createSCLValueIndependent valueType expression
33 claim container predicate value
36 setExpression :: Variable -> String -> <WriteGraph> ()
37 setExpression self expression = do
39 claimRelatedValue res L0.SCLValue.expression expression
41 importJava "org.simantics.modeling.ModelingUtils" where
42 createSCLModuleDefault :: Resource -> <WriteGraph> ()
43 createSCLScriptDefault :: Resource -> <WriteGraph> ()
44 createPGraphDefault :: Resource -> <WriteGraph> ()
45 "Use [createSCLModuleR](#createSCLModuleR) instead."
47 createSCLModule :: Resource -> String -> <WriteGraph> ()
48 "Use [createSCLScriptR](#createSCLScriptR) instead."
50 createSCLScript :: Resource -> String -> <WriteGraph> ()
51 "Use [createPGraphR](#createPGraphR) instead."
53 createPGraph :: Resource -> String -> <WriteGraph> ()
55 `createSCLModuleR container name` creates a new empty SCL module under
56 the specified `container` with the specified `name` and returns the created
59 @JavaName createSCLModule
60 createSCLModuleR :: Resource -> String -> <WriteGraph> Resource
62 `createSCLScriptR container name` creates a new empty SCL script under
63 the specified `container` with the specified `name` and returns the created
66 @JavaName createSCLScript
67 createSCLScriptR :: Resource -> String -> <WriteGraph> Resource
69 `createPGraphR container name` creates a new empty partial graph
70 ontology definition (PGraph) under the specified `container` with
71 the specified `name` and returns the created ontology definition's
74 @JavaName createPGraph
75 createPGraphR :: Resource -> String -> <WriteGraph> Resource
76 "`setSCLModuleDefinition module definition` sets the textual `definition` of the specified SCL `module`."
77 setSCLModuleDefinition :: Resource -> String -> <WriteGraph> Resource
78 "`setSCLScriptDefinition module definition` sets the textual `definition` of the specified SCL `module`."
79 setSCLScriptDefinition :: Resource -> String -> <WriteGraph> Resource
80 setPGraphDefinition :: Resource -> String -> <WriteGraph> Resource
83 `createSCLModuleWithDefinition container name definition` creates a new SCL module under
84 the specified `container` with the specified `name` and `definition` and returns
85 the created module's Resource.
87 createSCLModuleWithDefinition :: Resource -> String -> String -> <WriteGraph> Resource
88 createSCLModuleWithDefinition container name definition = setSCLModuleDefinition (createSCLModuleR container name) definition
91 `createSCLScriptWithDefinition container name definition` creates a new SCL script under
92 the specified `container` with the specified `name` and `definition` and returns
93 the created script's Resource.
95 createSCLScriptWithDefinition :: Resource -> String -> String -> <WriteGraph> Resource
96 createSCLScriptWithDefinition container name definition = setSCLScriptDefinition (createSCLScriptR container name) definition
100 "org.simantics.scl.compiler.commands.CommandSession"
102 importJava "org.simantics.modeling.scl.SCLRealm" where
104 syncExec :: SCLRealm -> (<SCL, Proc> a) -> <Proc> a
105 @JavaName refreshVariablesSync
106 refreshVariables :: SCLRealm -> <Proc> ()
108 readSCLRealm :: Resource -> <ReadGraph,Proc> SCLRealm
110 id = relatedValue r L0.HasName
111 in match sclRealmById id with
113 Nothing -> getOrCreateSCLRealm id
115 importJava "org.simantics.modeling.scl.SCLSessionManager" where
116 getOrCreateSCLRealm :: String -> <Proc> SCLRealm
117 sclRealmById :: String -> <Proc> Maybe SCLRealm
119 importJava "org.simantics.scl.compiler.top.CommandResponse" where
120 data CommandResponse =
121 @FieldNames [message, error]
122 CommandResponse String Boolean
124 isSuccessful :: CommandResponse -> Boolean
125 isSuccessful (CommandResponse _ error) = not error
127 instance Show CommandResponse where
128 show (CommandResponse message _) = message
130 importJava "org.simantics.scl.compiler.commands.CommandSession" where
131 execute :: String -> <SCL, Proc> ()
133 @JavaName getVariableValue
134 variableValue :: String -> <SCL> a
135 setVariable :: String -> Type -> a -> <SCL> ()