X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.db%2Fscl%2FSimantics%2FVariables.scl;h=47bf1a944cb92cdf824cce774e4fc6b385791f17;hp=9a6ffde8c17267717a3113d3ecfded655e262942;hb=545538ee3a2353eee994042800e6e5393177f858;hpb=ff1337ff96700fb157ec789cbef88b8f40e03798 diff --git a/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl b/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl index 9a6ffde8c..47bf1a944 100644 --- a/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl +++ b/bundles/org.simantics.scl.db/scl/Simantics/Variables.scl @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2019 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ include "Simantics/Model" include "Simantics/DB" import "Simantics/DB" as DB @@ -21,6 +32,9 @@ Example: """ variable :: String -> Variable + @JavaName getPossibleVariable + possibleResourceVariable :: Resource -> Maybe Variable + @JavaName getPossibleVariable possibleVariable :: String -> Maybe Variable @@ -93,6 +107,9 @@ 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 @@ -405,6 +422,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) @@ -414,6 +432,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 @@ -427,4 +448,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