]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.server/scl/Document/All.scl
Fixed broken validation of document SCL Handler expressions
[simantics/platform.git] / bundles / org.simantics.document.server / scl / Document / All.scl
index 98a63269978b01597d1d5ea7fb14628f39fec688..a90a24bcb62c30c55cad163eb3d242f869bec690 100644 (file)
@@ -2,6 +2,9 @@ import "Simantics/DB"
 import "Simantics/Variables"
 import "JavaBuiltin" as Java
 
+importJava "org.simantics.document.server.DocumentProperties" where
+    data DocumentProperties
+
 importJava "org.simantics.document.server.io.IConsole" where
     data IConsole
     addMessage :: IConsole -> String -> <Proc> ()
@@ -85,6 +88,9 @@ instance Coercible CommandContextMutable CommandContext where
 cloneCommandContext :: CommandContext -> <Proc> CommandContextMutable
 cloneCommandContext context = merge (commandContext ()) context
 
+instance Show CommandContext where
+    show ctx = printContext ctx
+
 importJava "org.simantics.document.server.io.CommandResult" where
     data CommandResult
 
@@ -99,7 +105,7 @@ importJava "org.simantics.document.server.Functions" where
     putTuple :: CommandContextMutable -> String -> a -> CommandContextMutable
 
     @JavaName getTuples
-    getTuples :: CommandContext -> String -> [a]
+    getTuples :: CommandContext -> String -> [Dynamic]
 
     printContext :: CommandContext -> String
 
@@ -107,6 +113,9 @@ importJava "org.simantics.document.server.Functions" where
 
     dataDefinitions :: Variable -> <ReadGraph> [DataDefinition]
 
+    @JavaName "dataDefinitions"
+    computeDataDefinitions :: Variable -> <ReadGraph> [DataDefinition]
+
     emptyOnClick :: () -> <ReadGraph> AbstractEventHandler
     
     writeEventHandler :: Variable -> (Variable -> (String -> Maybe String) -> <WriteGraph> String) -> <ReadGraph> AbstractEventHandler
@@ -134,6 +143,11 @@ importJava "org.simantics.document.server.Functions" where
     
     stateVariable :: Variable -> <ReadGraph> Variable
     
+    compileDocumentSCLValueExpression :: Variable -> <ReadGraph> String
+    compileDocumentSCLHandlerValueExpression :: Variable -> <ReadGraph> String
+
+    primitiveProperties :: <Proc> DocumentProperties
+    
 propertyValueCached :: Serializable a => Typeable a => Variable -> String -> <ReadGraph> a
 propertyValueCached var prop = propertyValueCached_ var prop binding
     
@@ -143,22 +157,10 @@ displayValue var str = propertyValue (property var str) "HasDisplayValue"
 displayValue0 :: Variable -> <ReadGraph> String
 displayValue0 var = propertyValue var "HasDisplayValue"
 
-consoleLog :: Variable -> String -> <ReadGraph> ()
-consoleLog state message = do
-    console = state#console
-    runProc $ addMessage console message
+consoleLog :: CommandContext -> String -> ()
+consoleLog context message = match possibleValue context "console" with
+  Nothing -> ()
+  Just console -> runProc $ addMessage console message
 
 contextDocument :: CommandContext -> <Proc> IDocument
 contextDocument ctx = justValue ctx "__document__"
-
-importJava "org.simantics.document.server.io.IRequest" where
-    @private
-    data IRequest
-    
-    @private
-    getParameter :: IRequest -> String -> <Proc> Maybe String
-
-possibleQueryParameterFromContext :: CommandContext -> String -> <Proc> Maybe String
-possibleQueryParameterFromContext context parameter = do
-    request = fromJust $ possibleValue context "__request__"
-    getParameter request parameter