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" */