X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.db%2Fscl%2FSimantics%2FVariables.scl;h=47bdaba3c7ebf3c044a46f3536bf4f743cc91fd7;hb=refs%2Fheads%2Fprivate%2Fantin_tyomaa;hp=1def7102cd72382f27baa20bc058b219048f80f8;hpb=0dc0aca2a1944a19ebece6c535386a8769e7871d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl b/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl index 1def7102c..47bdaba3c 100644 --- a/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl +++ b/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl @@ -21,6 +21,12 @@ Example: """ variable :: String -> Variable + @JavaName getPossibleVariable + possibleResourceVariable :: Resource -> Maybe Variable + + @JavaName getPossibleVariable + possibleVariable :: String -> Maybe Variable + @JavaName getVariable """ Function **resourceVariable** converts a resource to a corresponding variable. @@ -90,6 +96,13 @@ importJava "org.simantics.db.layer0.function.All" where importJava "org.simantics.db.layer0.variable.VariableMap" where data VariableMap +importJava "org.simantics.db.layer0.variable.StructuredProperty" where + data StructuredProperty + +importJava "org.simantics.db.layer0.variable.ResourceCollectionVariableMap" where + @JavaName "" + createVariableMap :: [Resource] -> VariableMap + importJava "org.simantics.db.layer0.variable.ValueAccessor" where data ValueAccessor @@ -398,6 +411,7 @@ instance Show Variable where instance Browsable Variable where fromUri = variable uriOf = uri + possibleUriOf v = Just (uri v) nameOf = name possibleNameOf v = Just (name v) children v = collectionToList (children_ v) @@ -407,6 +421,9 @@ instance Browsable Variable where variantValueOf v = createVariant (datatype v) (untypedValue v :: Dynamic) child = child_ possibleChild = possibleChild_ + + genericRelatedValue v rel = untypedPropertyValue v (nameOf rel) + genericPossibleRelatedValue v rel = untypedPossiblePropertyValue v (nameOf rel) propertiesClassified :: Variable -> Resource -> [Variable] propertiesClassified parent classified = do @@ -420,4 +437,15 @@ importJava "org.simantics.db.layer0.variable.RVI" where instantiateUnder :: Resource -> Resource -> Resource instantiateUnder container typeToInstantiate = do fn = (resourceVariable typeToInstantiate)#methods#instantiateUnder :: Resource -> Resource -> Resource - fn container typeToInstantiate \ No newline at end of file + fn container typeToInstantiate + +@JavaType "org.simantics.db.layer0.variable.VariableOrResource" +data VariableOrResource = + @JavaType "org.simantics.db.layer0.variable.ResourceX" + @FieldNames [value] + ResourceX Resource + | @JavaType "org.simantics.db.layer0.variable.VariableX" + @FieldNames [value] + VariableX Variable + + \ No newline at end of file