]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl
Removed uses of deprecated functions
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / UserComponent.scl
1 include "Simantics/Model"
2 import "Simantics/Diagram"
3 import "Simantics/Flag"
4 include "Simantics/Ontologies"
5
6 type UserComponent = Resource
7 type ComponentTypeConfiguration = Resource
8 type ComponentTypeProperty = Resource
9     
10 importJava "org.simantics.modeling.NewComponentType" where
11     @JavaName createComponentType
12     createUserComponent :: Model -> <WriteGraph> UserComponent
13     
14 configurationOfComponentType :: UserComponent -> <ReadGraph> Resource
15 configurationOfComponentType component = do
16       config = singleObject component STR.IsDefinedBy 
17       config
18       
19 importJava "org.simantics.modeling.flags.LiftFlag" where
20     liftFlag :: Resource -> <WriteGraph> Maybe String
21     
22 flagToTerminal :: Flag -> <WriteGraph> Resource
23 flagToTerminal flag = do
24     result = liftFlag flag
25     if result == Nothing
26     then singleObject flag DIA.IsLiftedAs
27     else flag
28
29 @deprecated "Calling this function is unnecessary."  
30 configToDiagram :: Resource -> Diagram
31 configToDiagram config = config
32
33 populateTerminalToSymbol :: Resource  -> (Double, Double) -> <WriteGraph> Element
34 populateTerminalToSymbol terminal (x, y) = element
35   where
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
41     claim diagram
42         L0.ConsistsOf
43         element
44     elementClass = singleObject terminal MOD.ConnectionRelationToTerminal
45     claim element
46         L0.InstanceOf
47         elementClass
48     s = ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v) :: Long)
49     claimRelatedValue element
50         L0.HasName
51         (show s)
52     claimRelatedValue diagram 
53         DIA.HasModCount
54         ((match possibleRelatedValue diagram DIA.HasModCount with Nothing -> 1 ; Just v -> v+1) :: Long)
55     claimRelatedValueWithType element
56         DIA.HasTransform
57         G2D.Transform
58         (toDoubleArray [1,0,0,1,x,y])
59     addToGraph diagram terminal element
60     addCommentMetadata ("Populated terminal " + (show element) + " to user component " + (show uc))
61     
62
63 importJava "org.simantics.modeling.symbolEditor.PopulateTerminal" where
64     addToGraph :: Resource -> Resource -> Resource -> <WriteGraph> ()
65
66 importJava "org.simantics.modeling.NewSymbolGroupRequest" where
67     createNewSymbolGroup :: Model -> String -> <WriteGraph> Resource
68
69 importJava "org.simantics.modeling.AssignSymbolGroupRequest" where
70     assignSymbolGroup :: [Resource] -> [Resource] -> [UserComponent] -> <WriteGraph> ()
71
72 importJava "org.simantics.modeling.GetSymbolGroups" where
73     getSymbolGroups :: Resource -> <ReadGraph> [Resource]
74
75 importJava "org.simantics.modeling.userComponent.ComponentTypeCommands" where
76     @JavaName createPropertyWithDefaults
77     createUserComponentProperty :: UserComponent -> <WriteGraph> Resource
78      
79     @JavaName rename
80     renameUserComponentProperty :: Resource -> String -> <WriteGraph> ()
81     
82     @JavaName setDescription
83     setUserComponentPropertyDescription :: Resource -> String -> <WriteGraph> ()
84     
85     @JavaName createMonitorPropertyWithDefaults
86     createUserComponentMonitorProperty :: UserComponent -> <WriteGraph> Resource
87     
88     setMonitorExpression :: Resource -> Resource -> String -> <WriteGraph> ()
89     
90     @JavaName setDefaultValue 
91     setUserComponentPropertyDefaultValue :: Resource -> Resource -> String -> <WriteGraph> ()
92     
93     @JavaName setUnit
94     setUserComponentPropertyUnit :: Resource -> Resource -> String -> <WriteGraph> ()
95     
96     @JavaName setRange
97     setUserComponentPropertyRange :: Resource -> Resource -> String -> <WriteGraph> ()
98     
99     @JavaName setLabel
100     setUserComponentPropertyLabel :: Resource -> String -> <WriteGraph> ()
101
102     @private
103     editType :: Resource -> Resource -> Boolean -> String -> <WriteGraph> ()
104     
105 setUserComponentPropertyRequiredType :: Resource -> Resource -> String -> <WriteGraph> ()
106 setUserComponentPropertyRequiredType componentType property newValue = do
107     editType componentType property True newValue
108  
109 importJava "org.simantics.modeling.UserComponentMigration" where
110     migrateUserComponents :: UserComponent -> UserComponent -> [Component] -> <WriteGraph> ()
111
112
113 /*
114     @JavaName newAnnotationProperty
115     createProperty :: UserComponent -> <WriteGraph> ComponentTypeProperty
116     
117     @JavaName advancedAnnotationProperty
118     createAdvancedProperty :: UserComponent -> String -> String -> String -> String -> String -> String -> <WriteGraph> ComponentTypeProperty
119
120     @JavaName removeAnnotationProperty
121     removeProperty :: UserComponent -> ComponentTypeProperty -> <WriteGraph> ()
122 */
123
124 """
125 `addUserComponentScript userComponent scriptType scriptCode` adds the script to the user component.
126 """
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