Package com.nomagic.magicdraw.validation
Class OpenedDiagramValidator
java.lang.Object
com.nomagic.magicdraw.validation.DiagramValidator
com.nomagic.magicdraw.validation.OpenedDiagramValidator
- All Implemented Interfaces:
com.nomagic.magicdraw.core.diagram.DiagramsChangeListener
,ValidationRule
@OpenApiAll
public abstract class OpenedDiagramValidator
extends DiagramValidator
implements com.nomagic.magicdraw.core.diagram.DiagramsChangeListener
Works the same as the base rule
DiagramValidator
, but narrows the scope down only to currently opened diagrams.
When creating annotations, the diagrams in scope should be retrieved by using DiagramValidator.getDiagrams()
method.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acceptDiagram
(DiagramPresentationElement diagram) void
diagramsChanged
(Collection<AbstractDiagramPresentationElement> opened, Collection<AbstractDiagramPresentationElement> closed) Called when opened diagrams changes.void
dispose()
Unregisters all listeners that were registered and releases other resources.void
init
(Project project, Constraint constraint) This is the first method that is invoked on the implementation of theValidationRule
interface.Methods inherited from class com.nomagic.magicdraw.validation.DiagramValidator
getAnnotations, getDiagrams, getDiagramsStream, getPresentationElements, getPresentationElements, getProject, isElementInScope, needsRun, needsRun, run, setNeedsRun
-
Constructor Details
-
OpenedDiagramValidator
public OpenedDiagramValidator()
-
-
Method Details
-
acceptDiagram
- Overrides:
acceptDiagram
in classDiagramValidator
- Returns:
- true if the diagram in scope should be returned by
DiagramValidator.getDiagrams()
method
-
init
Description copied from interface:ValidationRule
This is the first method that is invoked on the implementation of theValidationRule
interface. Implementation can initialize internal state if required.- Specified by:
init
in interfaceValidationRule
- Overrides:
init
in classDiagramValidator
- Parameters:
project
- a project of the constraintconstraint
- a constraint object
-
diagramsChanged
public void diagramsChanged(Collection<AbstractDiagramPresentationElement> opened, Collection<AbstractDiagramPresentationElement> closed) Called when opened diagrams changes. Should not be called manually.- Specified by:
diagramsChanged
in interfacecom.nomagic.magicdraw.core.diagram.DiagramsChangeListener
- Parameters:
opened
- newly opened diagrams including inner diagrams displayed within them.closed
- newly closed diagrams including inner diagrams, if the diagrams are no longer open in any other tab.
-
dispose
public void dispose()Description copied from class:DiagramValidator
Unregisters all listeners that were registered and releases other resources.- Specified by:
dispose
in interfaceValidationRule
- Overrides:
dispose
in classDiagramValidator
-