include "Simantics/DB" include "Simantics/Variables" include "Simantics/Ontologies" include "http://www.simantics.org/Modeling-1.2/SCLQuery" as SCLQuery importJava "org.simantics.scl.compiler.errors.CompilationError" where data CompilationError importJava "org.simantics.scl.ui.editor.TextAndErrors" where data TextAndErrors createTextAndErrors :: String -> [CompilationError] -> TextAndErrors createSCLModuleAction :: Resource -> () createSCLModuleAction res = do syncWrite (\() -> createSCLModuleDefault res) () createPGraphAction :: Resource -> () createPGraphAction res = do syncWrite (\() -> createPGraphDefault res) () createSCLValueIndependent :: Resource -> String -> Resource createSCLValueIndependent valueType expression = do value = newResource () claim value L0.InstanceOf valueType claimRelatedValue value L0.SCLValue.expression expression value createSCLValue :: Resource -> Resource -> Resource -> String -> Resource createSCLValue container predicate valueType expression = do value = createSCLValueIndependent valueType expression claim container predicate value value setExpression :: Variable -> String -> () setExpression self expression = do res = represents self claimRelatedValue res L0.SCLValue.expression expression importJava "org.simantics.modeling.ModelingUtils" where createSCLModuleDefault :: Resource -> () createPGraphDefault :: Resource -> () createSCLModule :: Resource -> String -> () effect SCL "scl" "org.simantics.scl.compiler.commands.CommandSession" importJava "org.simantics.modeling.scl.SCLRealm" where data SCLRealm syncExec :: SCLRealm -> ( a) -> a @JavaName refreshVariablesSync refreshVariables :: SCLRealm -> () readSCLRealm :: Resource -> SCLRealm readSCLRealm r = let id = relatedValue r L0.HasName in match sclRealmById id with Just realm -> realm Nothing -> getOrCreateSCLRealm id importJava "org.simantics.modeling.scl.SCLSessionManager" where getOrCreateSCLRealm :: String -> SCLRealm sclRealmById :: String -> Maybe SCLRealm importJava "org.simantics.scl.compiler.top.CommandResponse" where data CommandResponse = @FieldNames [message, error] CommandResponse String Boolean isSuccessful :: CommandResponse -> Boolean isSuccessful (CommandResponse _ error) = not error instance Show CommandResponse where show (CommandResponse message _) = message importJava "org.simantics.scl.compiler.commands.CommandSession" where execute :: String -> () @JavaName getVariableValue variableValue :: String -> a setVariable :: String -> Type -> a -> ()