1 include "Simantics/All"
4 useSelectedHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
5 useSelectedHandler input parameters = do
6 model = represents input
7 resources = map wseResource $ decodeWSES $ parameters "selection"
8 for resources $ linkSharedOntology model
11 unlinkSelectedHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
12 unlinkSelectedHandler input parameters = do
13 model = represents input
14 resources = map wseResource $ decodeWSES $ parameters "selection"
15 unlinkSharedOntologyWithUI input resources
18 createNewHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
19 createNewHandler input parameters = do
20 createSharedOntologyWithUI L0.SharedOntology
23 importHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
24 importHandler input parameters = do
25 importSharedOntologyWithUI input
28 fooHandler :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
29 fooHandler self ctx = do
30 val = fromJust $ possibleString ctx "selected"
31 setProjectComponentState self "currentSelection" val
34 availableRanges :: Variable -> <ReadGraph> [String]
35 availableRanges input = do
37 res = represents input
38 ranges = objectsWithType res L0.ConsistsOf SHEET.Range
41 defaultRange :: Variable -> <ReadGraph> String
42 defaultRange input = do
43 ranges = availableRanges input
44 if (length ranges) == 0 then "" else ranges!0
46 currentRangeName :: Variable -> Variable -> <ReadGraph> String
47 currentRangeName self input =
48 projectComponentState self "#currentSelection" (defaultRange input)
50 currentRangeExpressionVariable :: Variable -> Variable -> <ReadGraph> Variable
51 currentRangeExpressionVariable self input = do
52 name = projectComponentState self "./Combo#currentSelection" (defaultRange input)
53 browse input ("/" + name + "#cells")
55 currentRangeExpression :: Variable -> Variable -> <ReadGraph> String
56 currentRangeExpression self input = do
57 variable = currentRangeExpressionVariable self input
58 value $ browse variable "#expression"
60 currentRangeTextAndErrors :: Variable -> Variable -> <ReadGraph> TextAndErrors
61 currentRangeTextAndErrors self input = do
62 expression = currentRangeExpression self input
63 createTextAndErrors expression []
65 fooHandler2 :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
66 fooHandler2 self ctx = do
67 val = fromJust $ possibleString ctx "text"
68 setExpression self val
71 modifyCodeHandler :: Variable -> Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
72 modifyCodeHandler self input ctx = do
73 val = fromJust $ possibleString ctx "text"
74 variable = currentRangeExpressionVariable self input
75 setExpression variable val
78 standardPropertiesElementTransformation :: Variable -> <ReadGraph> Variable
79 standardPropertiesElementTransformation var = do
80 match getPossibleType var with
82 Just resourceType -> if isInheritedFrom resourceType DIA.Element then do
83 match possibleObject (represents var) MOD.ElementToComponent with
85 Just component -> resourceVariable component