Package com.nomagic.magicdraw.annotation
Class AnnotationManager
java.lang.Object
com.dassault_systemes.modeler.foundation.project.service.ModelElementProjectService<Project>
com.nomagic.magicdraw.core.project.service.ProjectService
com.nomagic.magicdraw.annotation.AnnotationManager
- All Implemented Interfaces:
com.dassault_systemes.modeler.foundation.project.service.DisposableService
,ProjectProvider
@OpenApiAll
public final class AnnotationManager
extends com.nomagic.magicdraw.core.project.service.ProjectService
implements ProjectProvider
Handles annotations visualization on diagrams and other UI components. It takes care of
drawing decorations around symbols with annotations and provides annotation actions for manipulators.
Users are responsible for adding annotations and removing added annotations afterwards.
Users is responsible to call update() method when some annotation is added or removed.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(Annotation annotation) Add single annotation.boolean
add
(Annotation annotation, AnnotationCategory category) Add single annotation.static void
void
addListener
(AnnotationManagerListener listener) void
Designed to be overridden in derived classesReturns a collection of annotated elementsgetAnnotatedElements
(AnnotationSubset subset) Returns a collection of annotated elementsgetAnnotatedTargets
(AnnotationSubset subset) Returns targets of the registered annotations.getAnnotations
(BaseElement element) Get all annotations for particular element.getAnnotations
(BaseElement element, AnnotationSubset subset) getAnnotations
(Object target) getAnnotations
(Object target, AnnotationSubset subset) getAnnotationsOfChildren
(BaseElement element) getAnnotationsOfChildren
(BaseElement element, AnnotationSubset subset) Get all annotations of children of given element.Get all annotations of closest hidden children(recursively) of given symbol.Get all annotations of closest hidden children(recursively) of given symbol.static AnnotationManager
getInstance
(Project project) static AnnotationManager
getInstance
(BaseElement element) Returns a collection of annotated elementsgetIteratorOfAnnotationsOfChildren
(BaseElement element, AnnotationSubset subset) static Project
getProject
(Object annotationTarget) Used to retrieve project from element or parent target providers if given object is not element.boolean
hasAnnotatedChildren
(BaseElement element) Test if given element has children (recursively) with some annotations.boolean
hasAnnotatedChildren
(BaseElement element, AnnotationSubset subset) Test if given element has children (recursively) with some annotations.boolean
boolean
hasAnnotations
(BaseElement element, AnnotationSubset subset) boolean
hasAnnotations
(Object target, AnnotationSubset subset) void
registerSubset
(AnnotationSubset subset) Register subset (part) of annotations.boolean
remove
(Annotation annotation) Remove single annotation.static void
void
removeListener
(AnnotationManagerListener listener) void
unregisterSubset
(AnnotationSubset subset) void
update()
Repaint opened diagrams and active browser tree.void
update
(boolean repaintBrowserTree) Repaint opened diagrams and (optionally) active browser tree.void
update
(Collection<? extends Annotation> removed, Collection<Annotation> added) Updates annotation manager using specified data.void
update
(Collection<? extends Annotation> removed, Collection<Annotation> added, AnnotationCategory category) Updates annotation manager using specified data.Methods inherited from class com.dassault_systemes.modeler.foundation.project.service.ModelElementProjectService
getIfPresent, getOrCreateInstance, getOrCreateInstanceWithNullSupport, getReferencedProject
-
Method Details
-
addAnnotationParentTargetProvider
-
removeAnnotationParentTargetProvider
-
getInstance
-
getInstance
-
add
Add single annotation. Annotation may not be visible until theupdate()
method has been called.- Parameters:
annotation
- annotation to add- Returns:
- true if annotation was added, false if such annotation already exists
-
add
Add single annotation. Annotation may not be visible until theupdate()
method has been called.- Parameters:
annotation
- annotation to addcategory
- category to which this annotation belongs. Each category can be part of various AnnotationSubsets- Returns:
- true if annotation was added, false if such annotation already exists
-
remove
Remove single annotation. Changes may not be visible until theupdate()
method has been called.- Parameters:
annotation
- annotation to remove- Returns:
- true if annotation was removed, false if such annotation was not added before
-
hasAnnotatedChildren
Test if given element has children (recursively) with some annotations.- Parameters:
element
- given element- Returns:
- true if there are at least one annotated child of given element
-
hasAnnotatedChildren
Test if given element has children (recursively) with some annotations.- Parameters:
element
- given elementsubset
- subset (part) of all currently registered annotations to check.- Returns:
- true if there are at least one annotated child of given element
-
getAnnotationsOfChildren
-
getAnnotationsOfChildren
Get all annotations of children of given element. Also includes informationFlows for given element.- Parameters:
element
- given elementsubset
- subset (part) of all currently registered children annotations to retrieve- Returns:
- list of annotations sorted by severity.
-
getAnnotationsOfHiddenChildren
Get all annotations of closest hidden children(recursively) of given symbol. Also includes InformationFlows of given element, that has conveyed Info.- Parameters:
view
- symbol of starting PE. dedicated to find closest hidden elements for diagrams.- Returns:
- list of annotations sorted by severity.
-
getAnnotationsOfHiddenChildren
public List<Annotation> getAnnotationsOfHiddenChildren(PresentationElement view, AnnotationSubset subset) Get all annotations of closest hidden children(recursively) of given symbol. Also includes InformationFlows of given element, that has conveyed Info.- Parameters:
view
- symbol of starting PE. dedicated to find closest hidden elements for diagrams.subset
- subset (part) of all currently registered hidden children annotations to check.- Returns:
- list of annotations sorted by severity.
-
getAnnotations
Get all annotations for particular element.- Parameters:
element
- element to get annotations for- Returns:
- unmodifiable list of annotations
-
getAnnotations
- Parameters:
element
- element to get annotations forsubset
- subset (part) of all currently registered annotations to retrieve.- Returns:
- unmodifiable subset of element's annotations
-
getAnnotations
-
getAnnotations
-
hasAnnotations
- Returns:
- true if there is one or more annotation added for the given element
-
hasAnnotations
-
update
public void update()Repaint opened diagrams and active browser tree. Fires updated event to registered listeners. -
update
public void update(boolean repaintBrowserTree) Repaint opened diagrams and (optionally) active browser tree. Fires updated event to registered listeners.- Parameters:
repaintBrowserTree
- true to repaint active browser tree (e.g. containment).
-
disposeService
public void disposeService()Description copied from class:com.dassault_systemes.modeler.foundation.project.service.ModelElementProjectService
Designed to be overridden in derived classes- Specified by:
disposeService
in interfacecom.dassault_systemes.modeler.foundation.project.service.DisposableService
- Overrides:
disposeService
in classcom.dassault_systemes.modeler.foundation.project.service.ModelElementProjectService<Project>
-
getProject
Used to retrieve project from element or parent target providers if given object is not element.- Parameters:
annotationTarget
- annotation target- Returns:
- project which annotation target exists in
-
getAnnotatedElements
Returns a collection of annotated elements- Returns:
- all annotated elements
-
getAnnotatedElements
Returns a collection of annotated elements- Parameters:
subset
- subset (part) of all currently registered annotations to take into account.- Returns:
- elements that have registered annotations belonging to the given subset
-
getAnnotatedTargets
Returns targets of the registered annotations.- Parameters:
subset
- subset (part) of all currently registered annotations to take into account.- Returns:
- all targets that have registered annotations belonging to the given subset
-
getIteratorOfAnnotatedElements
Returns a collection of annotated elements- Returns:
- all annotated elements
-
update
Updates annotation manager using specified data. No need to call update() method.- Parameters:
removed
- collection of removed annotations.added
- collection of added annotations.
-
update
public void update(Collection<? extends Annotation> removed, Collection<Annotation> added, AnnotationCategory category) Updates annotation manager using specified data. No need to call update() method.- Parameters:
removed
- collection of removed annotations.added
- collection of added annotations.category
- category to which annotations belongs
-
addListener
-
removeListener
-
hasAnnotations
public boolean hasAnnotations() -
getIteratorOfAnnotationsOfChildren
-
getIteratorOfAnnotationsOfChildren
public Iterator<Annotation> getIteratorOfAnnotationsOfChildren(BaseElement element, AnnotationSubset subset) -
registerSubset
Register subset (part) of annotations. This enables caching annotations by all the containing subsets. Only subsets, registered using this method, should be be used when retrieving annotations from the manager. -
unregisterSubset
-
getProject
- Specified by:
getProject
in interfaceProjectProvider
-