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 -> () sendEvent :: IConsole -> String -> String -> Vector Dynamic -> () importJava "org.simantics.document.server.io.IDocument" where data IDocument elementIdToObjectId :: IDocument -> String -> String getDocumentURI :: IDocument -> String getSessionGUID :: IDocument -> String importJava "org.simantics.document.server.io.ITableCell" where data ITableCell importJava "org.simantics.document.server.io.ITreeTableCell" where data ITreeTableCell importJava "org.simantics.document.server.io.IFont" where data IFont @JavaName getFamily fontFamily :: IFont -> Maybe String @JavaName getStyle fontStyle :: IFont -> Maybe String @JavaName getHeight fontHeight :: IFont -> Integer importJava "org.simantics.document.server.io.IColor" where data IColor importJava "org.simantics.modeling.services.ComponentNamingStrategy" where data ComponentNamingStrategy importJava "org.simantics.document.server.handler.EventHandler" where data EventHandler importJava "org.simantics.document.server.handler.AbstractEventHandler" where data AbstractEventHandler importJava "org.simantics.document.server.bean.Command" where data Command importJava "org.simantics.document.server.bean.DataDefinition" where data DataDefinition importJava "org.simantics.document.server.io.CommandContext" where data CommandContext @JavaName getString possibleString :: CommandContext -> String -> Maybe String @JavaName getValue possibleValue :: CommandContext -> String -> Maybe a @JavaName getValue justValue :: CommandContext -> String -> a @JavaName containsKey containsKey :: CommandContext -> String -> Boolean getKeys :: CommandContext -> [String] importJava "org.simantics.document.server.io.CommandContextMutable" where data CommandContextMutable @JavaName putString putString :: CommandContextMutable -> String -> String -> CommandContextMutable putValue :: CommandContextMutable -> String -> a -> CommandContextMutable merge :: CommandContextMutable -> CommandContext -> CommandContextMutable importJava "org.simantics.document.server.io.CommandContextImpl" where @JavaName create commandContext :: () -> CommandContextMutable instance Coercible CommandContextMutable CommandContext where coerce = Java.unsafeCoerce cloneCommandContext :: CommandContext -> CommandContextMutable cloneCommandContext context = merge (commandContext ()) context instance Show CommandContext where show ctx = printContext ctx importJava "org.simantics.document.server.io.CommandResult" where data CommandResult importJava "org.simantics.document.server.serverResponse.ServerResponse" where @JavaName create commandResult :: Integer -> String -> CommandContextMutable -> CommandResult importJava "org.simantics.document.server.Functions" where @JavaName putTuple putTuple :: CommandContextMutable -> String -> a -> CommandContextMutable @JavaName getTuples getTuples :: CommandContext -> String -> [Dynamic] printContext :: CommandContext -> String commandList :: Variable -> [Command] dataDefinitions :: Variable -> [DataDefinition] @JavaName "dataDefinitions" computeDataDefinitions :: Variable -> [DataDefinition] emptyOnClick :: () -> AbstractEventHandler writeEventHandler :: Variable -> (Variable -> (String -> Maybe String) -> String) -> AbstractEventHandler readEventHandler :: Variable -> (Variable -> (String -> Maybe String) -> String) -> AbstractEventHandler eventHandler :: ((String -> Maybe String) -> String) -> AbstractEventHandler readEventHandler2 :: (CommandContext -> Maybe CommandResult) -> AbstractEventHandler writeEventHandler2 :: (CommandContext -> Maybe CommandResult) -> AbstractEventHandler eventHandler2 :: (CommandContext -> Maybe CommandResult) -> AbstractEventHandler responseHandler :: Variable -> String -> AbstractEventHandler sclStateVariable :: Variable -> Variable -> String -> Variable sclStateValueOrDefault :: Variable -> Variable -> String -> a -> a setSclStateValue :: Variable -> Variable -> String -> a -> () projectComponentState :: Variable -> String -> a -> a setProjectComponentState :: Variable -> String -> a -> () documentModelContribution :: Resource -> [Variable] documentModelContributionLabel :: Variable -> String @JavaName getPropertyValueCached propertyValueCached_ :: Variable -> String -> Binding a -> a stateVariable :: Variable -> Variable compileDocumentSCLValueExpression :: Variable -> String compileDocumentSCLHandlerValueExpression :: Variable -> String primitiveProperties :: DocumentProperties contextVariable :: Variable -> Variable contextVariable var = propertyValue (variableParent var) "input" propertyValueCached :: Serializable a => Typeable a => Variable -> String -> a propertyValueCached var prop = propertyValueCached_ var prop binding displayValue :: Variable -> String -> String displayValue var str = propertyValue (property var str) "HasDisplayValue" displayValue0 :: Variable -> String displayValue0 var = propertyValue var "HasDisplayValue" consoleLog :: CommandContext -> String -> () consoleLog context message = match possibleValue context "console" with Nothing -> () Just console -> runProc $ addMessage console message contextDocument :: CommandContext -> IDocument contextDocument ctx = justValue ctx "__document__"