1 /*******************************************************************************
2 * Copyright (c) 2019 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 * Semantum Oy - reorganization
12 *******************************************************************************/
13 include "Simantics/All"
16 import "Simantics/IssueUI"
18 useSelectedHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
19 useSelectedHandler input parameters = do
20 model = represents input
21 resources = map wseResource $ decodeWSES $ parameters "selection"
22 for resources $ linkSharedOntology model
25 unlinkSelectedHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
26 unlinkSelectedHandler input parameters = do
27 model = represents input
28 resources = map wseResource $ decodeWSES $ parameters "selection"
29 unlinkSharedOntologyWithUI input resources
32 createNewHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
33 createNewHandler input parameters = do
34 createSharedOntologyWithUI L0.SharedOntology
37 importHandler :: Variable -> (String -> Maybe String) -> <WriteGraph> String
38 importHandler input parameters = do
39 importSharedOntologyWithUI input
42 fooHandler :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
43 fooHandler self ctx = do
44 val = fromJust $ possibleString ctx "selected"
45 setProjectComponentState self "currentSelection" val
48 availableRanges :: Variable -> <ReadGraph> [String]
49 availableRanges input = do
51 res = represents input
52 ranges = objectsWithType res L0.ConsistsOf SHEET.Range
55 defaultRange :: Variable -> <ReadGraph> String
56 defaultRange input = do
57 ranges = availableRanges input
58 if (length ranges) == 0 then "" else ranges!0
60 currentRangeName :: Variable -> Variable -> <ReadGraph> String
61 currentRangeName self input =
62 projectComponentState self "#currentSelection" (defaultRange input)
64 currentRangeExpressionVariable :: Variable -> Variable -> <ReadGraph> Variable
65 currentRangeExpressionVariable self input = do
66 name = projectComponentState self "./Combo#currentSelection" (defaultRange input)
67 browse input ("/" + name + "#cells")
69 currentRangeExpression :: Variable -> Variable -> <ReadGraph> String
70 currentRangeExpression self input = do
71 variable = currentRangeExpressionVariable self input
72 value $ browse variable "#expression"
74 currentRangeTextAndErrors :: Variable -> Variable -> <ReadGraph> TextAndErrors
75 currentRangeTextAndErrors self input = do
76 expression = currentRangeExpression self input
77 createTextAndErrors expression []
79 fooHandler2 :: Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
80 fooHandler2 self ctx = do
81 val = fromJust $ possibleString ctx "text"
82 setExpression self val
85 modifyCodeHandler :: Variable -> Variable -> CommandContext -> <WriteGraph> Maybe CommandResult
86 modifyCodeHandler self input ctx = do
87 val = fromJust $ possibleString ctx "text"
88 variable = currentRangeExpressionVariable self input
89 setExpression variable val
92 standardPropertiesElementTransformation :: Variable -> <ReadGraph> Variable
93 standardPropertiesElementTransformation var = do
94 match getPossibleType var with
96 Just resourceType -> if isInheritedFrom resourceType DIA.Element then do
97 match possibleObject (represents var) MOD.ElementToComponent with
99 Just component -> resourceVariable component
102 configureButtonClickHandler :: Resource -> CommandContext -> <Proc> Maybe CommandResult
103 configureButtonClickHandler indexRoot context = do
104 showIssueConfigurationDialog indexRoot
107 configureButtonClick :: Variable -> <ReadGraph,Proc> AbstractEventHandler
108 configureButtonClick self = do
109 indexRoot = represents $ contextVariable self
110 eventHandler2 $ configureButtonClickHandler indexRoot
112 validateButtonClickHandler :: Resource -> CommandContext -> <Proc> Maybe CommandResult
113 validateButtonClickHandler indexRoot context = do
114 runActiveValidations (createNullProgressMonitor ()) indexRoot
117 validateButtonClick :: Variable -> <ReadGraph,Proc> AbstractEventHandler
118 validateButtonClick self = do
119 indexRoot = represents $ contextVariable self
120 eventHandler2 $ validateButtonClickHandler indexRoot
122 issueSourceExplorerCheckHandler :: Resource -> CommandContext -> <Proc> Maybe CommandResult
123 issueSourceExplorerCheckHandler indexRoot context = match possibleValue context "item" with
125 Just issueSource -> match possibleValue context "checked" with
127 Just value -> if value then do
128 syncWrite $ \_ -> claim issueSource ISSUE.IssueSource.Selected (parent issueSource)
131 syncWrite $ \_ -> denyByPredicate issueSource ISSUE.IssueSource.Selected
134 issueSourceExplorerCheck :: Variable -> <ReadGraph,Proc> AbstractEventHandler
135 issueSourceExplorerCheck self = do
136 indexRoot = represents $ contextVariable self
137 eventHandler2 $ issueSourceExplorerCheckHandler indexRoot
139 usedIssueSources :: Resource -> <ReadGraph> [Resource]
140 usedIssueSources indexRoot = do
141 objectsWithType indexRoot L0.ConsistsOf ISSUE.IssueSource
143 checkedStateRule :: BrowseNodeRule CheckedState
144 checkedStateRule (ResourceX r) = if existsStatement r ISSUE.IssueSource.Selected then CHECKED else NOT_CHECKED