]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.platform.ui.ontology/graph/scl/SCLMain.scl
Fixed problems in shared libraries view
[simantics/platform.git] / bundles / org.simantics.platform.ui.ontology / graph / scl / SCLMain.scl
1 include "Simantics/All"
2 include "SWT/All"
3
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
9   ""
10
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
16   ""
17
18 createNewHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
19 createNewHandler input parameters = do
20   createSharedOntologyWithUI L0.SharedOntology
21   ""
22
23 importHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
24 importHandler input parameters = do
25   importSharedOntologyWithUI input
26   ""
27
28 fooHandler :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
29 fooHandler self ctx = do
30   val = fromJust $ possibleString ctx "selected"
31   setProjectComponentState self "currentSelection" val
32   Nothing
33   
34 availableRanges :: Variable -> <ReadGraph> [String]
35 availableRanges input = do
36   u = uri input
37   res = represents input
38   ranges = objectsWithType res L0.ConsistsOf SHEET.Range
39   map nameOf ranges
40   
41 defaultRange :: Variable -> <ReadGraph> String
42 defaultRange input = do
43   ranges = availableRanges input
44   if (length ranges) == 0 then "" else ranges!0
45
46 currentRangeName :: Variable -> Variable -> <ReadGraph> String
47 currentRangeName self input = 
48   projectComponentState self "#currentSelection" (defaultRange input)
49
50 currentRangeExpressionVariable :: Variable -> Variable -> <ReadGraph> Variable
51 currentRangeExpressionVariable self input = do
52   name = projectComponentState self "./Combo#currentSelection" (defaultRange input)
53   browse input ("/" + name + "#cells")
54
55 currentRangeExpression :: Variable -> Variable -> <ReadGraph> String
56 currentRangeExpression self input = do
57   variable = currentRangeExpressionVariable self input
58   value $ browse variable "#expression"
59
60 currentRangeTextAndErrors :: Variable -> Variable -> <ReadGraph> TextAndErrors
61 currentRangeTextAndErrors self input = do
62   expression = currentRangeExpression self input
63   createTextAndErrors expression []
64
65 fooHandler2 :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
66 fooHandler2 self ctx = do
67   val = fromJust $ possibleString ctx "text"
68   setExpression self val
69   Nothing
70
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
76   Nothing
77
78 standardPropertiesElementTransformation :: Variable -> <ReadGraph> Variable
79 standardPropertiesElementTransformation var = do
80   match getPossibleType var with
81     Nothing -> var
82     Just resourceType -> if isInheritedFrom resourceType DIA.Element then do
83         match possibleObject (represents var) MOD.ElementToComponent with
84           Nothing -> var
85           Just component -> resourceVariable component
86       else var
87