1 include "Simantics/DB"
\r
2 include "Simantics/Variables"
\r
3 include "Simantics/Ontologies"
\r
5 include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery
\r
7 importJava "org.simantics.scl.compiler.errors.CompilationError" where
\r
8 data CompilationError
\r
10 importJava "org.simantics.scl.ui.editor.TextAndErrors" where
\r
12 createTextAndErrors :: String -> [CompilationError] -> TextAndErrors
\r
14 createSCLModuleAction :: Resource -> <Proc> ()
\r
15 createSCLModuleAction res = do
\r
16 syncWrite (\() -> createSCLModuleDefault res)
\r
19 createPGraphAction :: Resource -> <Proc> ()
\r
20 createPGraphAction res = do
\r
21 syncWrite (\() -> createPGraphDefault res)
\r
24 createSCLValueIndependent :: Resource -> String -> <WriteGraph> Resource
\r
25 createSCLValueIndependent valueType expression = do
\r
26 value = newResource ()
\r
27 claim value L0.InstanceOf valueType
\r
28 claimRelatedValue value L0.SCLValue.expression expression
\r
31 createSCLValue :: Resource -> Resource -> Resource -> String -> <WriteGraph> Resource
\r
32 createSCLValue container predicate valueType expression = do
\r
33 value = createSCLValueIndependent valueType expression
\r
34 claim container predicate value
\r
37 setExpression :: Variable -> String -> <WriteGraph> ()
\r
38 setExpression self expression = do
\r
39 res = represents self
\r
40 claimRelatedValue res L0.SCLValue.expression expression
\r
42 importJava "org.simantics.modeling.ModelingUtils" where
\r
43 createSCLModuleDefault :: Resource -> <WriteGraph> ()
\r
44 createPGraphDefault :: Resource -> <WriteGraph> ()
\r
45 createSCLModule :: Resource -> String -> <WriteGraph> ()
\r
49 "org.simantics.scl.compiler.commands.CommandSession"
\r
51 importJava "org.simantics.modeling.scl.SCLRealm" where
\r
53 syncExec :: SCLRealm -> (<SCL, Proc> a) -> <Proc> a
\r
54 @JavaName refreshVariablesSync
\r
55 refreshVariables :: SCLRealm -> <Proc> ()
\r
57 readSCLRealm :: Resource -> <ReadGraph,Proc> SCLRealm
\r
58 readSCLRealm r = let
\r
59 id = relatedValue r L0.HasName
\r
60 in match sclRealmById id with
\r
62 Nothing -> getOrCreateSCLRealm id
\r
64 importJava "org.simantics.modeling.scl.SCLSessionManager" where
\r
65 getOrCreateSCLRealm :: String -> <Proc> SCLRealm
\r
66 sclRealmById :: String -> <Proc> Maybe SCLRealm
\r
68 importJava "org.simantics.scl.compiler.top.CommandResponse" where
\r
69 data CommandResponse =
\r
70 @FieldNames [message, error]
\r
71 CommandResponse String Boolean
\r
73 isSuccessful :: CommandResponse -> Boolean
\r
74 isSuccessful (CommandResponse _ error) = not error
\r
76 instance Show CommandResponse where
\r
77 show (CommandResponse message _) = message
\r
79 importJava "org.simantics.scl.compiler.commands.CommandSession" where
\r
80 execute :: String -> <SCL, Proc> ()
\r
82 @JavaName getVariableValue
\r
83 variableValue :: String -> <SCL> a
\r
84 setVariable :: String -> Type -> a -> <SCL> ()