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 (toResource 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 (toResource flag)
26 then singleObject (toResource flag) DIA.IsLiftedAs
31 configToDiagram :: Resource -> Diagram
32 configToDiagram config = do
35 populateTerminalToSymbol :: Resource -> (Double, Double) -> <WriteGraph> Element
36 populateTerminalToSymbol terminal (x, y) = do
37 uc = singleObject terminal L0.PartOf
38 symbol = singleObject uc MOD.ComponentTypeToSymbol
39 diagram = singleObject symbol STR.IsDefinedBy
40 element = newResource ()
41 addToOrderedSet diagram element
45 elementClass = singleObject terminal MOD.ConnectionRelationToTerminal
49 s = ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v) :: Long)
50 claimRelatedValue element
53 claimRelatedValue diagram
55 ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v+1) :: Long)
56 claimRelatedValueWithType element
59 (toDoubleArray [1,0,0,1,x,y])
60 addToGraph diagram terminal element
61 addCommentMetadata ("Populated terminal " + (show element) + " to user component " + (show uc))
62 (fromResource element)
64 importJava "org.simantics.modeling.symbolEditor.PopulateTerminal" where
65 addToGraph :: Resource -> Resource -> Resource -> <WriteGraph> ()
67 importJava "org.simantics.modeling.NewSymbolGroupRequest" where
68 createNewSymbolGroup :: Model -> String -> <WriteGraph> Resource
70 importJava "org.simantics.modeling.AssignSymbolGroupRequest" where
71 assignSymbolGroup :: [Resource] -> [Resource] -> [UserComponent] -> <WriteGraph> ()
73 importJava "org.simantics.modeling.GetSymbolGroups" where
74 getSymbolGroups :: Resource -> <ReadGraph> [Resource]
76 importJava "org.simantics.modeling.userComponent.ComponentTypeCommands" where
77 @JavaName createPropertyWithDefaults
78 createUserComponentProperty :: UserComponent -> <WriteGraph> Resource
81 renameUserComponentProperty :: Resource -> String -> <WriteGraph> ()
83 @JavaName setDescription
84 setUserComponentPropertyDescription :: Resource -> String -> <WriteGraph> ()
86 @JavaName createMonitorPropertyWithDefaults
87 createUserComponentMonitorProperty :: UserComponent -> <WriteGraph> Resource
89 setMonitorExpression :: Resource -> Resource -> String -> <WriteGraph> ()
91 @JavaName setDefaultValue
92 setUserComponentPropertyDefaultValue :: Resource -> Resource -> String -> <WriteGraph> ()
95 setUserComponentPropertyUnit :: Resource -> Resource -> String -> <WriteGraph> ()
98 setUserComponentPropertyRange :: Resource -> Resource -> String -> <WriteGraph> ()
101 setUserComponentPropertyLabel :: Resource -> String -> <WriteGraph> ()
104 editType :: Resource -> Resource -> Boolean -> String -> <WriteGraph> ()
106 setUserComponentPropertyRequiredType :: Resource -> Resource -> String -> <WriteGraph> ()
107 setUserComponentPropertyRequiredType componentType property newValue = do
108 editType componentType property True newValue
110 importJava "org.simantics.modeling.UserComponentMigration" where
111 migrateUserComponents :: UserComponent -> UserComponent -> [Component] -> <WriteGraph> ()
115 @JavaName newAnnotationProperty
116 createProperty :: UserComponent -> <WriteGraph> ComponentTypeProperty
118 @JavaName advancedAnnotationProperty
119 createAdvancedProperty :: UserComponent -> String -> String -> String -> String -> String -> String -> <WriteGraph> ComponentTypeProperty
121 @JavaName removeAnnotationProperty
122 removeProperty :: UserComponent -> ComponentTypeProperty -> <WriteGraph> ()
126 `addUserComponentScript userComponent scriptType scriptCode` adds the script to the user component.
128 addUserComponentScript :: Resource -> String -> String -> String -> <WriteGraph> ()
129 addUserComponentScript userComponent scriptName scriptType scriptCode = do
130 script = newResource ()
131 claim script L0.InstanceOf STR.ComponentTypeScript
132 claim userComponent STR.ComponentType.hasScript script
133 claimRelatedValue script L0.HasName scriptName
134 claimRelatedValue script STR.ComponentTypeScript.type scriptType
135 claimRelatedValue script STR.ComponentTypeScript.code scriptCode