-include "Simantics/Model"\r
-import "Simantics/Diagram"\r
-import "Simantics/Flag"\r
-include "Simantics/Ontologies"\r
-\r
-type UserComponent = Resource\r
-type ComponentTypeConfiguration = Resource\r
-type ComponentTypeProperty = Resource\r
- \r
-importJava "org.simantics.modeling.NewComponentType" where\r
- @JavaName createComponentType\r
- createUserComponent :: Model -> <WriteGraph> UserComponent\r
- \r
-configurationOfComponentType :: UserComponent -> <ReadGraph> Resource\r
-configurationOfComponentType component = do\r
- config = singleObject (toResource component) STR.IsDefinedBy \r
- config\r
- \r
-importJava "org.simantics.modeling.flags.LiftFlag" where\r
- liftFlag :: Resource -> <WriteGraph> Maybe String\r
- \r
-flagToTerminal :: Flag -> <WriteGraph> Resource\r
-flagToTerminal flag = do\r
- result = liftFlag (toResource flag)\r
- if result == Nothing\r
- then singleObject (toResource flag) DIA.IsLiftedAs\r
- else do\r
- show result\r
- (toResource flag)\r
- \r
-configToDiagram :: Resource -> Diagram\r
-configToDiagram config = do\r
- fromResource config\r
-\r
-populateTerminalToSymbol :: Resource -> (Double, Double) -> <WriteGraph> Element\r
-populateTerminalToSymbol terminal (x, y) = do\r
- uc = singleObject terminal L0.PartOf\r
- symbol = singleObject uc MOD.ComponentTypeToSymbol\r
- diagram = singleObject symbol STR.IsDefinedBy\r
- element = newResource ()\r
- addToOrderedSet diagram element\r
- claim diagram\r
- L0.ConsistsOf\r
- element\r
- elementClass = singleObject terminal MOD.ConnectionRelationToTerminal\r
- claim element\r
- L0.InstanceOf\r
- elementClass\r
- s = ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v) :: Long)\r
- claimRelatedValue element\r
- L0.HasName\r
- (show s)\r
- claimRelatedValue diagram \r
- DIA.HasModCount\r
- ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v+1) :: Long)\r
- claimRelatedValueWithType element\r
- DIA.HasTransform\r
- G2D.Transform\r
- (toDoubleArray [1,0,0,1,x,y])\r
- addToGraph diagram terminal element\r
- addCommentMetadata ("Populated terminal " + (show element) + " to user component " + (show uc))\r
- (fromResource element)\r
-\r
-importJava "org.simantics.modeling.symbolEditor.PopulateTerminal" where\r
- addToGraph :: Resource -> Resource -> Resource -> <WriteGraph> ()\r
-\r
-importJava "org.simantics.modeling.NewSymbolGroupRequest" where\r
- createNewSymbolGroup :: Model -> String -> <WriteGraph> Resource\r
-\r
-importJava "org.simantics.modeling.AssignSymbolGroupRequest" where\r
- assignSymbolGroup :: [Resource] -> [Resource] -> [UserComponent] -> <WriteGraph> ()\r
-\r
-importJava "org.simantics.modeling.GetSymbolGroups" where\r
- getSymbolGroups :: Resource -> <ReadGraph> [Resource]\r
-\r
-importJava "org.simantics.modeling.userComponent.ComponentTypeCommands" where\r
- @JavaName createPropertyWithDefaults\r
- createUserComponentProperty :: UserComponent -> <WriteGraph> Resource\r
- \r
- @JavaName rename\r
- renameUserComponentProperty :: Resource -> String -> <WriteGraph> ()\r
- \r
- @JavaName setDescription\r
- setUserComponentPropertyDescription :: Resource -> String -> <WriteGraph> ()\r
- \r
- @JavaName createMonitorPropertyWithDefaults\r
- createUserComponentMonitorProperty :: UserComponent -> <WriteGraph> Resource\r
- \r
- setMonitorExpression :: Resource -> Resource -> String -> <WriteGraph> ()\r
- \r
- @JavaName setDefaultValue \r
- setUserComponentPropertyDefaultValue :: Resource -> Resource -> String -> <WriteGraph> ()\r
- \r
- @JavaName setUnit\r
- setUserComponentPropertyUnit :: Resource -> Resource -> String -> <WriteGraph> ()\r
- \r
- @JavaName setRange\r
- setUserComponentPropertyRange :: Resource -> Resource -> String -> <WriteGraph> ()\r
- \r
- @JavaName setLabel\r
- setUserComponentPropertyLabel :: Resource -> String -> <WriteGraph> ()\r
-\r
- @private\r
- editType :: Resource -> Resource -> Boolean -> String -> <WriteGraph> ()\r
- \r
-setUserComponentPropertyRequiredType :: Resource -> Resource -> String -> <WriteGraph> ()\r
-setUserComponentPropertyRequiredType componentType property newValue = do\r
- editType componentType property True newValue\r
- \r
-importJava "org.simantics.modeling.UserComponentMigration" where\r
- migrateUserComponents :: UserComponent -> UserComponent -> [Component] -> <WriteGraph> ()\r
-\r
-\r
-/*\r
- @JavaName newAnnotationProperty\r
- createProperty :: UserComponent -> <WriteGraph> ComponentTypeProperty\r
- \r
- @JavaName advancedAnnotationProperty\r
- createAdvancedProperty :: UserComponent -> String -> String -> String -> String -> String -> String -> <WriteGraph> ComponentTypeProperty\r
-\r
- @JavaName removeAnnotationProperty\r
- removeProperty :: UserComponent -> ComponentTypeProperty -> <WriteGraph> ()\r
-*/\r
-\r
-"""\r
-`addUserComponentScript userComponent scriptType scriptCode` adds the script to the user component.\r
-"""\r
-addUserComponentScript :: Resource -> String -> String -> String -> <WriteGraph> ()\r
-addUserComponentScript userComponent scriptName scriptType scriptCode = do\r
- script = newResource ()\r
- claim script L0.InstanceOf STR.ComponentTypeScript\r
- claim userComponent STR.ComponentType.hasScript script\r
- claimRelatedValue script L0.HasName scriptName\r
- claimRelatedValue script STR.ComponentTypeScript.type scriptType \r
- claimRelatedValue script STR.ComponentTypeScript.code scriptCode \r
+include "Simantics/Model"
+import "Simantics/Diagram"
+import "Simantics/Flag"
+include "Simantics/Ontologies"
+
+type UserComponent = Resource
+type ComponentTypeConfiguration = Resource
+type ComponentTypeProperty = Resource
+
+importJava "org.simantics.modeling.NewComponentType" where
+ @JavaName createComponentType
+ createUserComponent :: Model -> <WriteGraph> UserComponent
+
+configurationOfComponentType :: UserComponent -> <ReadGraph> Resource
+configurationOfComponentType component = do
+ config = singleObject (toResource component) STR.IsDefinedBy
+ config
+
+importJava "org.simantics.modeling.flags.LiftFlag" where
+ liftFlag :: Resource -> <WriteGraph> Maybe String
+
+flagToTerminal :: Flag -> <WriteGraph> Resource
+flagToTerminal flag = do
+ result = liftFlag (toResource flag)
+ if result == Nothing
+ then singleObject (toResource flag) DIA.IsLiftedAs
+ else do
+ show result
+ (toResource flag)
+
+configToDiagram :: Resource -> Diagram
+configToDiagram config = do
+ fromResource config
+
+populateTerminalToSymbol :: Resource -> (Double, Double) -> <WriteGraph> Element
+populateTerminalToSymbol terminal (x, y) = do
+ uc = singleObject terminal L0.PartOf
+ symbol = singleObject uc MOD.ComponentTypeToSymbol
+ diagram = singleObject symbol STR.IsDefinedBy
+ element = newResource ()
+ addToOrderedSet diagram element
+ claim diagram
+ L0.ConsistsOf
+ element
+ elementClass = singleObject terminal MOD.ConnectionRelationToTerminal
+ claim element
+ L0.InstanceOf
+ elementClass
+ s = ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v) :: Long)
+ claimRelatedValue element
+ L0.HasName
+ (show s)
+ claimRelatedValue diagram
+ DIA.HasModCount
+ ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v+1) :: Long)
+ claimRelatedValueWithType element
+ DIA.HasTransform
+ G2D.Transform
+ (toDoubleArray [1,0,0,1,x,y])
+ addToGraph diagram terminal element
+ addCommentMetadata ("Populated terminal " + (show element) + " to user component " + (show uc))
+ (fromResource element)
+
+importJava "org.simantics.modeling.symbolEditor.PopulateTerminal" where
+ addToGraph :: Resource -> Resource -> Resource -> <WriteGraph> ()
+
+importJava "org.simantics.modeling.NewSymbolGroupRequest" where
+ createNewSymbolGroup :: Model -> String -> <WriteGraph> Resource
+
+importJava "org.simantics.modeling.AssignSymbolGroupRequest" where
+ assignSymbolGroup :: [Resource] -> [Resource] -> [UserComponent] -> <WriteGraph> ()
+
+importJava "org.simantics.modeling.GetSymbolGroups" where
+ getSymbolGroups :: Resource -> <ReadGraph> [Resource]
+
+importJava "org.simantics.modeling.userComponent.ComponentTypeCommands" where
+ @JavaName createPropertyWithDefaults
+ createUserComponentProperty :: UserComponent -> <WriteGraph> Resource
+
+ @JavaName rename
+ renameUserComponentProperty :: Resource -> String -> <WriteGraph> ()
+
+ @JavaName setDescription
+ setUserComponentPropertyDescription :: Resource -> String -> <WriteGraph> ()
+
+ @JavaName createMonitorPropertyWithDefaults
+ createUserComponentMonitorProperty :: UserComponent -> <WriteGraph> Resource
+
+ setMonitorExpression :: Resource -> Resource -> String -> <WriteGraph> ()
+
+ @JavaName setDefaultValue
+ setUserComponentPropertyDefaultValue :: Resource -> Resource -> String -> <WriteGraph> ()
+
+ @JavaName setUnit
+ setUserComponentPropertyUnit :: Resource -> Resource -> String -> <WriteGraph> ()
+
+ @JavaName setRange
+ setUserComponentPropertyRange :: Resource -> Resource -> String -> <WriteGraph> ()
+
+ @JavaName setLabel
+ setUserComponentPropertyLabel :: Resource -> String -> <WriteGraph> ()
+
+ @private
+ editType :: Resource -> Resource -> Boolean -> String -> <WriteGraph> ()
+
+setUserComponentPropertyRequiredType :: Resource -> Resource -> String -> <WriteGraph> ()
+setUserComponentPropertyRequiredType componentType property newValue = do
+ editType componentType property True newValue
+
+importJava "org.simantics.modeling.UserComponentMigration" where
+ migrateUserComponents :: UserComponent -> UserComponent -> [Component] -> <WriteGraph> ()
+
+
+/*
+ @JavaName newAnnotationProperty
+ createProperty :: UserComponent -> <WriteGraph> ComponentTypeProperty
+
+ @JavaName advancedAnnotationProperty
+ createAdvancedProperty :: UserComponent -> String -> String -> String -> String -> String -> String -> <WriteGraph> ComponentTypeProperty
+
+ @JavaName removeAnnotationProperty
+ removeProperty :: UserComponent -> ComponentTypeProperty -> <WriteGraph> ()
+*/
+
+"""
+`addUserComponentScript userComponent scriptType scriptCode` adds the script to the user component.
+"""
+addUserComponentScript :: Resource -> String -> String -> String -> <WriteGraph> ()
+addUserComponentScript userComponent scriptName scriptType scriptCode = do
+ script = newResource ()
+ claim script L0.InstanceOf STR.ComponentTypeScript
+ claim userComponent STR.ComponentType.hasScript script
+ claimRelatedValue script L0.HasName scriptName
+ claimRelatedValue script STR.ComponentTypeScript.type scriptType
+ claimRelatedValue script STR.ComponentTypeScript.code scriptCode