X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.platform.ui.ontology%2Fgraph%2Fscl%2FSCLMain.scl;fp=bundles%2Forg.simantics.platform.ui.ontology%2Fgraph%2Fscl%2FSCLMain.scl;h=83bb80ea893ab44f8c906e10df0d51ad0d9c6cb4;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=5ba23f43d572218257987160b2ecf53b494dd142;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.platform.ui.ontology/graph/scl/SCLMain.scl b/bundles/org.simantics.platform.ui.ontology/graph/scl/SCLMain.scl index 5ba23f43d..83bb80ea8 100644 --- a/bundles/org.simantics.platform.ui.ontology/graph/scl/SCLMain.scl +++ b/bundles/org.simantics.platform.ui.ontology/graph/scl/SCLMain.scl @@ -1,83 +1,83 @@ -include "Simantics/All" -include "SWT/All" - -usedSharedOntologies2 :: Variable -> [Resource] -usedSharedOntologies2 model = usedSharedOntologies $ represents model - -availableSharedOntologies2 :: Variable -> [Resource] -availableSharedOntologies2 model = availableSharedOntologies $ represents model - -useSelectedHandler :: Variable -> (String -> Maybe String) -> String -useSelectedHandler input parameters = do - model = represents input - resources = map wseResource $ decodeWSES $ parameters "selection" - for resources $ linkSharedOntology model - "" - -unlinkSelectedHandler :: Variable -> (String -> Maybe String) -> String -unlinkSelectedHandler input parameters = do - model = represents input - resources = map wseResource $ decodeWSES $ parameters "selection" - unlinkSharedOntologyWithUI input resources - "" - -createNewHandler :: Variable -> (String -> Maybe String) -> String -createNewHandler input parameters = do - createSharedOntologyWithUI L0.SharedOntology - "" - -importHandler :: Variable -> (String -> Maybe String) -> String -importHandler input parameters = do - importSharedOntologyWithUI input - "" - -fooHandler :: Variable -> CommandContext -> Maybe CommandResult -fooHandler self ctx = do - val = fromJust $ possibleString ctx "selected" - setProjectComponentState self "currentSelection" val - Nothing - -availableRanges :: Variable -> [String] -availableRanges input = do - u = uri input - res = represents input - ranges = objectsWithType res L0.ConsistsOf SHEET.Range - map nameOf ranges - -defaultRange :: Variable -> String -defaultRange input = do - ranges = availableRanges input - if (length ranges) == 0 then "" else ranges!0 - -currentRangeName :: Variable -> Variable -> String -currentRangeName self input = - projectComponentState self "#currentSelection" (defaultRange input) - -currentRangeExpressionVariable :: Variable -> Variable -> Variable -currentRangeExpressionVariable self input = do - name = projectComponentState self "./Combo#currentSelection" (defaultRange input) - browse input ("/" + name + "#cells") - -currentRangeExpression :: Variable -> Variable -> String -currentRangeExpression self input = do - variable = currentRangeExpressionVariable self input - value $ browse variable "#expression" - -currentRangeTextAndErrors :: Variable -> Variable -> TextAndErrors -currentRangeTextAndErrors self input = do - expression = currentRangeExpression self input - createTextAndErrors expression [] - -fooHandler2 :: Variable -> CommandContext -> Maybe CommandResult -fooHandler2 self ctx = do - val = fromJust $ possibleString ctx "text" - setExpression self val - Nothing - -modifyCodeHandler :: Variable -> Variable -> CommandContext -> Maybe CommandResult -modifyCodeHandler self input ctx = do - val = fromJust $ possibleString ctx "text" - variable = currentRangeExpressionVariable self input - setExpression variable val - Nothing +include "Simantics/All" +include "SWT/All" + +usedSharedOntologies2 :: Variable -> [Resource] +usedSharedOntologies2 model = usedSharedOntologies $ represents model + +availableSharedOntologies2 :: Variable -> [Resource] +availableSharedOntologies2 model = availableSharedOntologies $ represents model + +useSelectedHandler :: Variable -> (String -> Maybe String) -> String +useSelectedHandler input parameters = do + model = represents input + resources = map wseResource $ decodeWSES $ parameters "selection" + for resources $ linkSharedOntology model + "" + +unlinkSelectedHandler :: Variable -> (String -> Maybe String) -> String +unlinkSelectedHandler input parameters = do + model = represents input + resources = map wseResource $ decodeWSES $ parameters "selection" + unlinkSharedOntologyWithUI input resources + "" + +createNewHandler :: Variable -> (String -> Maybe String) -> String +createNewHandler input parameters = do + createSharedOntologyWithUI L0.SharedOntology + "" + +importHandler :: Variable -> (String -> Maybe String) -> String +importHandler input parameters = do + importSharedOntologyWithUI input + "" + +fooHandler :: Variable -> CommandContext -> Maybe CommandResult +fooHandler self ctx = do + val = fromJust $ possibleString ctx "selected" + setProjectComponentState self "currentSelection" val + Nothing + +availableRanges :: Variable -> [String] +availableRanges input = do + u = uri input + res = represents input + ranges = objectsWithType res L0.ConsistsOf SHEET.Range + map nameOf ranges + +defaultRange :: Variable -> String +defaultRange input = do + ranges = availableRanges input + if (length ranges) == 0 then "" else ranges!0 + +currentRangeName :: Variable -> Variable -> String +currentRangeName self input = + projectComponentState self "#currentSelection" (defaultRange input) + +currentRangeExpressionVariable :: Variable -> Variable -> Variable +currentRangeExpressionVariable self input = do + name = projectComponentState self "./Combo#currentSelection" (defaultRange input) + browse input ("/" + name + "#cells") + +currentRangeExpression :: Variable -> Variable -> String +currentRangeExpression self input = do + variable = currentRangeExpressionVariable self input + value $ browse variable "#expression" + +currentRangeTextAndErrors :: Variable -> Variable -> TextAndErrors +currentRangeTextAndErrors self input = do + expression = currentRangeExpression self input + createTextAndErrors expression [] + +fooHandler2 :: Variable -> CommandContext -> Maybe CommandResult +fooHandler2 self ctx = do + val = fromJust $ possibleString ctx "text" + setExpression self val + Nothing + +modifyCodeHandler :: Variable -> Variable -> CommandContext -> Maybe CommandResult +modifyCodeHandler self input ctx = do + val = fromJust $ possibleString ctx "text" + variable = currentRangeExpressionVariable self input + setExpression variable val + Nothing \ No newline at end of file