]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.platform.ui.ontology/graph/scl/SCLMain.scl
44bf61267b7b9fbe0f6fc0b2eda98534f62dcab8
[simantics/platform.git] / bundles / org.simantics.platform.ui.ontology / graph / scl / SCLMain.scl
1 include "Simantics/All"
2 include "SWT/All"
3
4 usedSharedOntologies2 :: Variable -> <ReadGraph> [Resource]
5 usedSharedOntologies2 model = usedSharedOntologies $ represents model
6
7 availableSharedOntologies2 :: Variable -> <ReadGraph> [Resource]
8 availableSharedOntologies2 model = availableSharedOntologies $ represents model
9
10 useSelectedHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
11 useSelectedHandler input parameters = do
12   model = represents input
13   resources = map wseResource $ decodeWSES $ parameters "selection"
14   for resources $ linkSharedOntology model
15   ""
16
17 unlinkSelectedHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
18 unlinkSelectedHandler input parameters = do
19   model = represents input
20   resources = map wseResource $ decodeWSES $ parameters "selection"
21   unlinkSharedOntologyWithUI input resources
22   ""
23
24 createNewHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
25 createNewHandler input parameters = do
26   createSharedOntologyWithUI L0.SharedOntology
27   ""
28
29 importHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
30 importHandler input parameters = do
31   importSharedOntologyWithUI input
32   ""
33
34 fooHandler :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
35 fooHandler self ctx = do
36   val = fromJust $ possibleString ctx "selected"
37   setProjectComponentState self "currentSelection" val
38   Nothing
39   
40 availableRanges :: Variable -> <ReadGraph> [String]
41 availableRanges input = do
42   u = uri input
43   res = represents input
44   ranges = objectsWithType res L0.ConsistsOf SHEET.Range
45   map nameOf ranges
46   
47 defaultRange :: Variable -> <ReadGraph> String
48 defaultRange input = do
49   ranges = availableRanges input
50   if (length ranges) == 0 then "" else ranges!0
51
52 currentRangeName :: Variable -> Variable -> <ReadGraph> String
53 currentRangeName self input = 
54   projectComponentState self "#currentSelection" (defaultRange input)
55
56 currentRangeExpressionVariable :: Variable -> Variable -> <ReadGraph> Variable
57 currentRangeExpressionVariable self input = do
58   name = projectComponentState self "./Combo#currentSelection" (defaultRange input)
59   browse input ("/" + name + "#cells")
60
61 currentRangeExpression :: Variable -> Variable -> <ReadGraph> String
62 currentRangeExpression self input = do
63   variable = currentRangeExpressionVariable self input
64   value $ browse variable "#expression"
65
66 currentRangeTextAndErrors :: Variable -> Variable -> <ReadGraph> TextAndErrors
67 currentRangeTextAndErrors self input = do
68   expression = currentRangeExpression self input
69   createTextAndErrors expression []
70
71 fooHandler2 :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
72 fooHandler2 self ctx = do
73   val = fromJust $ possibleString ctx "text"
74   setExpression self val
75   Nothing
76
77 modifyCodeHandler :: Variable -> Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
78 modifyCodeHandler self input ctx = do
79   val = fromJust $ possibleString ctx "text"
80   variable = currentRangeExpressionVariable self input
81   setExpression variable val
82   Nothing
83
84 standardPropertiesElementTransformation :: Variable -> <ReadGraph> Variable
85 standardPropertiesElementTransformation var = do
86   match getPossibleType var with
87     Nothing -> var
88     Just resourceType -> if isInheritedFrom resourceType DIA.Element then do
89         match possibleObject (represents var) MOD.ElementToComponent with
90           Nothing -> var
91           Just component -> resourceVariable component
92       else var
93