]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.annotation.ui/scl/Simantics/Annotation2.scl
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.annotation.ui / scl / Simantics / Annotation2.scl
index ab97387d6be76b82605fe97909b578da6fedf80c..cd3f851cbf8afd65de822d935d20ad179424d47f 100644 (file)
-import "Simantics/DB"\r
-import "Simantics/Variables"\r
-import "Simantics/Model"\r
-import "Simantics/Diagram"\r
-import "Simantics/Library"\r
-import "Simantics/Misc"\r
-import "Simantics/DB" as DB\r
-\r
-import "http://www.simantics.org/Layer0-1.1" as L0\r
-import "http://www.simantics.org/Layer0-1.1/HasRange" as HasRange\r
-import "http://www.simantics.org/Annotation-1.0" as ANNO\r
-\r
-type Annotation = Resource\r
-type AnnotationPropertyRelation = Resource\r
-type AnnotationType = Resource\r
-type AnnotationValue = Resource\r
-type AnnotationProperty = Resource\r
-\r
-importJava "org.simantics.annotation.ui.SCLAnnotation" where\r
-    @JavaName newAnnotationType\r
-    """\r
-    Creates new AnnotationType under the given Library instance and returns it without PropertyRelation\r
-    """\r
-    newAnnotationType :: Library -> <WriteGraph> AnnotationType\r
-    \r
-    @JavaName newAnnotationValue\r
-    """\r
-    Creates new AnnotationValue under the given Library instance with the AnnotationType reference. Returns the created AnnotationValue.\r
-    """\r
-    newAnnotationValue :: Library -> AnnotationType -> <WriteGraph> AnnotationValue\r
-    newAnnotationValueWithName :: Library -> String -> AnnotationType -> <WriteGraph> AnnotationValue\r
-    \r
-    @JavaName newAnnotationType1\r
-    """\r
-    Creates new AnnotationType under the given Library instance. Returns a Tuple2 consisting the AnnotationPropertyRelation and AnnotationType instances.\r
-    """\r
-    newAnnotationType1 :: Library -> <WriteGraph> (AnnotationPropertyRelation, AnnotationType)\r
-    \r
-    @JavaName newAnnotationProperty\r
-    """\r
-    Creates new AnnotationProperty under the given AnnotatoinType instance. Returns the created AnnotationProperty.\r
-    """\r
-    newAnnotationProperty :: AnnotationType -> <WriteGraph> AnnotationProperty\r
-    \r
-    @JavaName advancedAnnotationProperty\r
-    """\r
-    Creates new AnnotationProperty under the given AnnotationType instance with advanced options for user to define non-default parameters for the following values\r
-    \r
-    * name\r
-    * type\r
-    * unit\r
-    * range\r
-    * label\r
-    * description\r
-    """\r
-    advancedAnnotationProperty :: AnnotationType -> String -> String -> String -> String -> String -> String -> <WriteGraph> AnnotationProperty\r
-    \r
-    @JavaName removeAnnotationProperty\r
-    """\r
-    Removes the given AnnotationProperty instance.\r
-    """\r
-    removeAnnotationProperty :: AnnotationProperty -> <WriteGraph> ()\r
-    \r
-    @JavaName attachAnnotation\r
-    """\r
-    Attaches the given AnnotationType to the given Resource which can be for example a Diagram or a Symbol.\r
-    """\r
-    attachAnnotationType :: Resource -> AnnotationType -> <WriteGraph> Annotation\r
-    \r
-    @JavaName setPropertyLabel\r
-    setPropertyLabel :: AnnotationProperty -> String -> <WriteGraph> ()\r
-    \r
-    @JavaName setPropertyUnit\r
-    setPropertyUnit :: AnnotationProperty -> String -> <WriteGraph> ()\r
-    \r
-    @JavaName setPropertyRange\r
-    setPropertyRange :: AnnotationProperty -> String -> <WriteGraph> ()\r
-    \r
-    @JavaName setPropertyDescription\r
-    setPropertyDescription :: AnnotationProperty -> String -> <WriteGraph> ()\r
-    \r
-    @JavaName setPropertyType\r
-    setPropertyType :: AnnotationProperty -> String -> <WriteGraph> ()\r
-    \r
-    @JavaName saveAnnotation\r
-    saveAnnotation :: Annotation -> Library -> String -> <WriteGraph> Resource\r
-    \r
-    @JavaName importAnnotationFromFile\r
-    importAnnotation :: File -> Library -> <Proc> ()\r
-    \r
-    @JavaName exportAnnotationToFile\r
-    exportAnnotationType :: File -> AnnotationType -> <Proc> ()\r
-    \r
-    @JavaName copyAnnotationData\r
-    copyAnnotationData :: Resource -> Resource -> <WriteGraph> ()\r
-\r
-getAnnotationNameFromType :: Resource -> <ReadGraph> String\r
-getAnnotationNameFromType annotationType = do\r
-    relation = singleObject annotationType HasRange.Inverse\r
-    untypedRelatedValue relation L0.HasName\r
-\r
-getPossibleAnnotationType :: Resource -> String -> <ReadGraph> Maybe AnnotationType\r
-getPossibleAnnotationType model name = do\r
-    all = searchByType model ANNO.AnnotationType\r
-    named = filter (\x -> (getAnnotationNameFromType x) == name) all \r
-    if ((length named) == 1)\r
-     then Just (fromResource $ named!0) \r
-     else Nothing\r
-    \r
-setAnnotationPropertyValue :: AnnotationPropertyRelation -> Resource -> String -> String -> <WriteGraph> ()\r
-setAnnotationPropertyValue annotation resource property newValue = do\r
-    resourceUri = uriOf resource\r
-    annotationName = DB.nameOf (toResource annotation)\r
-    completeUri = resourceUri + "#" + annotationName + "#" + property + "#HasDisplayValue"\r
-    propertyVariable = variable completeUri\r
-    setValue propertyVariable newValue\r
-    \r
-/*  \r
-findAnnotationType :: Model -> [AnnotationType]\r
-findAnnotationType m = do\r
-    fromResource $ searchByQuery m "Types: AnnotationType"\r
-*/\r
+import "Simantics/DB"
+import "Simantics/Variables"
+import "Simantics/Model"
+import "Simantics/Diagram"
+import "Simantics/Library"
+import "Simantics/Misc"
+import "Simantics/DB" as DB
+
+import "http://www.simantics.org/Layer0-1.1" as L0
+import "http://www.simantics.org/Layer0-1.1/HasRange" as HasRange
+import "http://www.simantics.org/Annotation-1.0" as ANNO
+
+type Annotation = Resource
+type AnnotationPropertyRelation = Resource
+type AnnotationType = Resource
+type AnnotationValue = Resource
+type AnnotationProperty = Resource
+
+importJava "org.simantics.annotation.ui.SCLAnnotation" where
+    @JavaName newAnnotationType
+    """
+    Creates new AnnotationType under the given Library instance and returns it without PropertyRelation
+    """
+    newAnnotationType :: Library -> <WriteGraph> AnnotationType
+    
+    @JavaName newAnnotationValue
+    """
+    Creates new AnnotationValue under the given Library instance with the AnnotationType reference. Returns the created AnnotationValue.
+    """
+    newAnnotationValue :: Library -> AnnotationType -> <WriteGraph> AnnotationValue
+    newAnnotationValueWithName :: Library -> String -> AnnotationType -> <WriteGraph> AnnotationValue
+    
+    @JavaName newAnnotationType1
+    """
+    Creates new AnnotationType under the given Library instance. Returns a Tuple2 consisting the AnnotationPropertyRelation and AnnotationType instances.
+    """
+    newAnnotationType1 :: Library -> <WriteGraph> (AnnotationPropertyRelation, AnnotationType)
+    
+    @JavaName newAnnotationProperty
+    """
+    Creates new AnnotationProperty under the given AnnotatoinType instance. Returns the created AnnotationProperty.
+    """
+    newAnnotationProperty :: AnnotationType -> <WriteGraph> AnnotationProperty
+    
+    @JavaName advancedAnnotationProperty
+    """
+    Creates new AnnotationProperty under the given AnnotationType instance with advanced options for user to define non-default parameters for the following values
+    
+    * name
+    * type
+    * unit
+    * range
+    * label
+    * description
+    """
+    advancedAnnotationProperty :: AnnotationType -> String -> String -> String -> String -> String -> String -> <WriteGraph> AnnotationProperty
+    
+    @JavaName removeAnnotationProperty
+    """
+    Removes the given AnnotationProperty instance.
+    """
+    removeAnnotationProperty :: AnnotationProperty -> <WriteGraph> ()
+    
+    @JavaName attachAnnotation
+    """
+    Attaches the given AnnotationType to the given Resource which can be for example a Diagram or a Symbol.
+    """
+    attachAnnotationType :: Resource -> AnnotationType -> <WriteGraph> Annotation
+    
+    @JavaName setPropertyLabel
+    setPropertyLabel :: AnnotationProperty -> String -> <WriteGraph> ()
+    
+    @JavaName setPropertyUnit
+    setPropertyUnit :: AnnotationProperty -> String -> <WriteGraph> ()
+    
+    @JavaName setPropertyRange
+    setPropertyRange :: AnnotationProperty -> String -> <WriteGraph> ()
+    
+    @JavaName setPropertyDescription
+    setPropertyDescription :: AnnotationProperty -> String -> <WriteGraph> ()
+    
+    @JavaName setPropertyType
+    setPropertyType :: AnnotationProperty -> String -> <WriteGraph> ()
+    
+    @JavaName saveAnnotation
+    saveAnnotation :: Annotation -> Library -> String -> <WriteGraph> Resource
+    
+    @JavaName importAnnotationFromFile
+    importAnnotation :: File -> Library -> <Proc> ()
+    
+    @JavaName exportAnnotationToFile
+    exportAnnotationType :: File -> AnnotationType -> <Proc> ()
+    
+    @JavaName copyAnnotationData
+    copyAnnotationData :: Resource -> Resource -> <WriteGraph> ()
+
+getAnnotationNameFromType :: Resource -> <ReadGraph> String
+getAnnotationNameFromType annotationType = do
+    relation = singleObject annotationType HasRange.Inverse
+    untypedRelatedValue relation L0.HasName
+
+getPossibleAnnotationType :: Resource -> String -> <ReadGraph> Maybe AnnotationType
+getPossibleAnnotationType model name = do
+    all = searchByType model ANNO.AnnotationType
+    named = filter (\x -> (getAnnotationNameFromType x) == name) all 
+    if ((length named) == 1)
+     then Just (fromResource $ named!0) 
+     else Nothing
+    
+setAnnotationPropertyValue :: AnnotationPropertyRelation -> Resource -> String -> String -> <WriteGraph> ()
+setAnnotationPropertyValue annotation resource property newValue = do
+    resourceUri = uriOf resource
+    annotationName = DB.nameOf (toResource annotation)
+    completeUri = resourceUri + "#" + annotationName + "#" + property + "#HasDisplayValue"
+    propertyVariable = variable completeUri
+    setValue propertyVariable newValue
+    
+/*  
+findAnnotationType :: Model -> [AnnotationType]
+findAnnotationType m = do
+    fromResource $ searchByQuery m "Types: AnnotationType"
+*/