X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.annotation.ui%2Fscl%2FSimantics%2FAnnotation2.scl;h=cd3f851cbf8afd65de822d935d20ad179424d47f;hb=refs%2Fchanges%2F38%2F238%2F2;hp=ab97387d6be76b82605fe97909b578da6fedf80c;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.annotation.ui/scl/Simantics/Annotation2.scl b/bundles/org.simantics.annotation.ui/scl/Simantics/Annotation2.scl index ab97387d6..cd3f851cb 100644 --- a/bundles/org.simantics.annotation.ui/scl/Simantics/Annotation2.scl +++ b/bundles/org.simantics.annotation.ui/scl/Simantics/Annotation2.scl @@ -1,122 +1,122 @@ -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 -> AnnotationType - - @JavaName newAnnotationValue - """ - Creates new AnnotationValue under the given Library instance with the AnnotationType reference. Returns the created AnnotationValue. - """ - newAnnotationValue :: Library -> AnnotationType -> AnnotationValue - newAnnotationValueWithName :: Library -> String -> AnnotationType -> AnnotationValue - - @JavaName newAnnotationType1 - """ - Creates new AnnotationType under the given Library instance. Returns a Tuple2 consisting the AnnotationPropertyRelation and AnnotationType instances. - """ - newAnnotationType1 :: Library -> (AnnotationPropertyRelation, AnnotationType) - - @JavaName newAnnotationProperty - """ - Creates new AnnotationProperty under the given AnnotatoinType instance. Returns the created AnnotationProperty. - """ - newAnnotationProperty :: AnnotationType -> 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 -> AnnotationProperty - - @JavaName removeAnnotationProperty - """ - Removes the given AnnotationProperty instance. - """ - removeAnnotationProperty :: AnnotationProperty -> () - - @JavaName attachAnnotation - """ - Attaches the given AnnotationType to the given Resource which can be for example a Diagram or a Symbol. - """ - attachAnnotationType :: Resource -> AnnotationType -> Annotation - - @JavaName setPropertyLabel - setPropertyLabel :: AnnotationProperty -> String -> () - - @JavaName setPropertyUnit - setPropertyUnit :: AnnotationProperty -> String -> () - - @JavaName setPropertyRange - setPropertyRange :: AnnotationProperty -> String -> () - - @JavaName setPropertyDescription - setPropertyDescription :: AnnotationProperty -> String -> () - - @JavaName setPropertyType - setPropertyType :: AnnotationProperty -> String -> () - - @JavaName saveAnnotation - saveAnnotation :: Annotation -> Library -> String -> Resource - - @JavaName importAnnotationFromFile - importAnnotation :: File -> Library -> () - - @JavaName exportAnnotationToFile - exportAnnotationType :: File -> AnnotationType -> () - - @JavaName copyAnnotationData - copyAnnotationData :: Resource -> Resource -> () - -getAnnotationNameFromType :: Resource -> String -getAnnotationNameFromType annotationType = do - relation = singleObject annotationType HasRange.Inverse - untypedRelatedValue relation L0.HasName - -getPossibleAnnotationType :: Resource -> String -> 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 -> () -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" -*/ +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 -> AnnotationType + + @JavaName newAnnotationValue + """ + Creates new AnnotationValue under the given Library instance with the AnnotationType reference. Returns the created AnnotationValue. + """ + newAnnotationValue :: Library -> AnnotationType -> AnnotationValue + newAnnotationValueWithName :: Library -> String -> AnnotationType -> AnnotationValue + + @JavaName newAnnotationType1 + """ + Creates new AnnotationType under the given Library instance. Returns a Tuple2 consisting the AnnotationPropertyRelation and AnnotationType instances. + """ + newAnnotationType1 :: Library -> (AnnotationPropertyRelation, AnnotationType) + + @JavaName newAnnotationProperty + """ + Creates new AnnotationProperty under the given AnnotatoinType instance. Returns the created AnnotationProperty. + """ + newAnnotationProperty :: AnnotationType -> 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 -> AnnotationProperty + + @JavaName removeAnnotationProperty + """ + Removes the given AnnotationProperty instance. + """ + removeAnnotationProperty :: AnnotationProperty -> () + + @JavaName attachAnnotation + """ + Attaches the given AnnotationType to the given Resource which can be for example a Diagram or a Symbol. + """ + attachAnnotationType :: Resource -> AnnotationType -> Annotation + + @JavaName setPropertyLabel + setPropertyLabel :: AnnotationProperty -> String -> () + + @JavaName setPropertyUnit + setPropertyUnit :: AnnotationProperty -> String -> () + + @JavaName setPropertyRange + setPropertyRange :: AnnotationProperty -> String -> () + + @JavaName setPropertyDescription + setPropertyDescription :: AnnotationProperty -> String -> () + + @JavaName setPropertyType + setPropertyType :: AnnotationProperty -> String -> () + + @JavaName saveAnnotation + saveAnnotation :: Annotation -> Library -> String -> Resource + + @JavaName importAnnotationFromFile + importAnnotation :: File -> Library -> () + + @JavaName exportAnnotationToFile + exportAnnotationType :: File -> AnnotationType -> () + + @JavaName copyAnnotationData + copyAnnotationData :: Resource -> Resource -> () + +getAnnotationNameFromType :: Resource -> String +getAnnotationNameFromType annotationType = do + relation = singleObject annotationType HasRange.Inverse + untypedRelatedValue relation L0.HasName + +getPossibleAnnotationType :: Resource -> String -> 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 -> () +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" +*/