1 include "Simantics/Model"
2 import "Simantics/Diagram"
3 import "Simantics/Flag"
4 include "Simantics/Ontologies"
6 type UserComponent = Resource
7 type ComponentTypeConfiguration = Resource
8 type ComponentTypeProperty = Resource
10 importJava "org.simantics.modeling.NewComponentType" where
11 @JavaName createComponentType
12 createUserComponent :: Model -> <WriteGraph> UserComponent
14 configurationOfComponentType :: UserComponent -> <ReadGraph> Resource
15 configurationOfComponentType component = do
16 config = singleObject component STR.IsDefinedBy
19 importJava "org.simantics.modeling.flags.LiftFlag" where
20 liftFlag :: Resource -> <WriteGraph> Maybe String
22 flagToTerminal :: Flag -> <WriteGraph> Resource
23 flagToTerminal flag = do
24 result = liftFlag flag
26 then singleObject flag DIA.IsLiftedAs
29 @deprecated "Calling this function is unnecessary."
30 configToDiagram :: Resource -> Diagram
31 configToDiagram config = config
33 populateTerminalToSymbol :: Resource -> (Double, Double) -> <WriteGraph> Element
34 populateTerminalToSymbol terminal (x, y) = element
36 uc = singleObject terminal L0.PartOf
37 symbol = singleObject uc MOD.ComponentTypeToSymbol
38 diagram = singleObject symbol STR.IsDefinedBy
39 element = newResource ()
40 addToOrderedSet diagram element
44 elementClass = singleObject terminal MOD.ConnectionRelationToTerminal
48 s = ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v) :: Long)
49 claimRelatedValue element
52 claimRelatedValue diagram
54 ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v+1) :: Long)
55 claimRelatedValueWithType element
58 (toDoubleArray [1,0,0,1,x,y])
59 addToGraph diagram terminal element
60 addCommentMetadata ("Populated terminal " + (show element) + " to user component " + (show uc))
63 importJava "org.simantics.modeling.symbolEditor.PopulateTerminal" where
64 addToGraph :: Resource -> Resource -> Resource -> <WriteGraph> ()
66 importJava "org.simantics.modeling.NewSymbolGroupRequest" where
67 createNewSymbolGroup :: Model -> String -> <WriteGraph> Resource
69 importJava "org.simantics.modeling.AssignSymbolGroupRequest" where
70 assignSymbolGroup :: [Resource] -> [Resource] -> [UserComponent] -> <WriteGraph> ()
72 importJava "org.simantics.modeling.GetSymbolGroups" where
73 getSymbolGroups :: Resource -> <ReadGraph> [Resource]
75 importJava "org.simantics.modeling.userComponent.ComponentTypeCommands" where
76 @JavaName createPropertyWithDefaults
77 createUserComponentProperty :: UserComponent -> <WriteGraph> Resource
80 renameUserComponentProperty :: Resource -> String -> <WriteGraph> ()
82 @JavaName setDescription
83 setUserComponentPropertyDescription :: Resource -> String -> <WriteGraph> ()
85 @JavaName createMonitorPropertyWithDefaults
86 createUserComponentMonitorProperty :: UserComponent -> <WriteGraph> Resource
88 setMonitorExpression :: Resource -> Resource -> String -> <WriteGraph> ()
90 @JavaName setDefaultValue
91 setUserComponentPropertyDefaultValue :: Resource -> Resource -> String -> <WriteGraph> ()
94 setUserComponentPropertyUnit :: Resource -> Resource -> String -> <WriteGraph> ()
97 setUserComponentPropertyRange :: Resource -> Resource -> String -> <WriteGraph> ()
100 setUserComponentPropertyLabel :: Resource -> String -> <WriteGraph> ()
103 editType :: Resource -> Resource -> Boolean -> String -> <WriteGraph> ()
105 setUserComponentPropertyRequiredType :: Resource -> Resource -> String -> <WriteGraph> ()
106 setUserComponentPropertyRequiredType componentType property newValue = do
107 editType componentType property True newValue
109 importJava "org.simantics.modeling.UserComponentMigration" where
110 migrateUserComponents :: UserComponent -> UserComponent -> [Component] -> <WriteGraph> ()
114 @JavaName newAnnotationProperty
115 createProperty :: UserComponent -> <WriteGraph> ComponentTypeProperty
117 @JavaName advancedAnnotationProperty
118 createAdvancedProperty :: UserComponent -> String -> String -> String -> String -> String -> String -> <WriteGraph> ComponentTypeProperty
120 @JavaName removeAnnotationProperty
121 removeProperty :: UserComponent -> ComponentTypeProperty -> <WriteGraph> ()
125 `addUserComponentScript userComponent scriptType scriptCode` adds the script to the user component.
127 addUserComponentScript :: Resource -> String -> String -> String -> <WriteGraph> ()
128 addUserComponentScript userComponent scriptName scriptType scriptCode = do
129 script = newResource ()
130 claim script L0.InstanceOf STR.ComponentTypeScript
131 claim userComponent STR.ComponentType.hasScript script
132 claimRelatedValue script L0.HasName scriptName
133 claimRelatedValue script STR.ComponentTypeScript.type scriptType
134 claimRelatedValue script STR.ComponentTypeScript.code scriptCode