Class ModelElementsManager
java.lang.Object
com.nomagic.magicdraw.openapi.uml.ModelElementsManager
The utility class for ModelElements adding, removing and moving to other parents.
Also it helps to create all 7 types of diagrams.
Works together with
SessionManager
.
This manager can be used only if some session was created with SessionManager. See code sample in SessionManager description for more details.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(Element element, Element parent) Adds given element into the given parent.createDiagram
(String type, Namespace parent) Creates new Diagram of given type.createDiagram
(String type, Namespace parent, boolean openDiagram, boolean openInActiveTab) Creates new Diagram of given type.static ModelElementsManager
Returns an instance of this manager.void
moveElement
(Element element, Element parent) Moves given element from current parent into the given one.void
removeElement
(com.dassault_systemes.modeler.foundation.model.ModelElement element) Removes given element from the model.void
removeElement
(Element element) Removes given element from the model.
-
Method Details
-
getInstance
Returns an instance of this manager.- Returns:
- instance of this manager.Pro
-
addElement
Adds given element into the given parent.- Parameters:
element
- the given model element to add into the given parent.parent
- the given model element parent.- Throws:
IllegalStateException
- if session is not created with SessionManagerIllegalArgumentException
- given model element cannot be added into given parent. For example Operation cannot be added into Package or Operation cannot be added into not locked for editing Class(in teamwork project). Also it is thrown if element or parent is null.ReadOnlyElementException
- if given element is not editable(read only).- See Also:
-
moveElement
Moves given element from current parent into the given one.- Parameters:
element
- the given ModelElement to move into the given parent.parent
- a new parent for given ModelElement.- Throws:
IllegalStateException
- if session is not created with SessionManagerIllegalArgumentException
- given ModelElement cannot be added into given parent. For example Operation cannot be added into Package or Operation cannot be added into not locked for editing Class(in teamwork project). Also this exception is thrown if new parent already has the same type child with the same name as given element. It is thrown if element or parent is null, too.ReadOnlyElementException
- if given element is not editable(read only).- See Also:
-
removeElement
Removes given element from the model.- Parameters:
element
- the given ModelElement to remove.- Throws:
IllegalStateException
- if session is not created with SessionManager.IllegalArgumentException
- if given element is null.ReadOnlyElementException
- if given element is not editable(read only).- See Also:
-
removeElement
public void removeElement(com.dassault_systemes.modeler.foundation.model.ModelElement element) throws ReadOnlyElementException Removes given element from the model.- Parameters:
element
- the given ModelElement to remove.- Throws:
IllegalStateException
- if session is not created with SessionManager.IllegalArgumentException
- if given element is null.ReadOnlyElementException
- if given element is not editable(read only).- See Also:
-
createDiagram
Creates new Diagram of given type. All available types are predefined in constants class DiagramTypeConstants. The created diagram instance is added into parent.- Parameters:
type
- diagram typeparent
- diagram owner- Returns:
- The created diagram.
- Throws:
IllegalStateException
- if session is not created with SessionManagerIllegalArgumentException
- if given type is unknown. if given model element cannot be added into given parent. For example Operation cannot be added into Package or Operation cannot be added into not locked for editing Class(in teamwork project). Also it is thrown if element or parent is null.ReadOnlyElementException
- if parent element is not editable(read only).- See Also:
-
DiagramTypes.UML_CLASS_DIAGRAM
DiagramTypes.UML_USECASE_DIAGRAM
DiagramTypes.UML_COMMUNICATION_DIAGRAM
DiagramTypes.UML_SEQUENCE_DIAGRAM
DiagramTypes.UML_STATECHART_DIAGRAM
DiagramTypes.UML_PROTOCOL_STATE_MACHINE_DIAGRAM
DiagramTypes.UML_ACTIVITY_DIAGRAM
DiagramTypes.UML_OBJECT_DIAGRAM
DiagramTypes.UML_PACKAGE_DIAGRAM
DiagramTypes.UML_COMPONENT_DIAGRAM
DiagramTypes.UML_DEPLOYMENT_DIAGRAM
DiagramTypes.UML_PROFILE_DIAGRAM
DiagramTypes.UML_COMPOSITE_STRUCTURE_DIAGRAM
-
createDiagram
public Diagram createDiagram(String type, Namespace parent, boolean openDiagram, boolean openInActiveTab) throws ReadOnlyElementException Creates new Diagram of given type. All available types are predefined in constants class DiagramTypeConstants. The created diagram instance is added into parent.- Parameters:
type
- diagram typeparent
- diagram owneropenDiagram
- if open created diagramopenInActiveTab
- if open diagram in active tab if we open diagram- Returns:
- The created diagram.
- Throws:
IllegalStateException
- if session is not created with SessionManagerIllegalArgumentException
- if given type is unknown. if given model element cannot be added into given parent. For example Operation cannot be added into Package or Operation cannot be added into not locked for editing Class(in teamwork project). Also it is thrown if element or parent is null.ReadOnlyElementException
- if parent element is not editable(read only).- See Also:
-
DiagramTypes.UML_CLASS_DIAGRAM
DiagramTypes.UML_USECASE_DIAGRAM
DiagramTypes.UML_COMMUNICATION_DIAGRAM
DiagramTypes.UML_SEQUENCE_DIAGRAM
DiagramTypes.UML_STATECHART_DIAGRAM
DiagramTypes.UML_PROTOCOL_STATE_MACHINE_DIAGRAM
DiagramTypes.UML_ACTIVITY_DIAGRAM
DiagramTypes.UML_OBJECT_DIAGRAM
DiagramTypes.UML_PACKAGE_DIAGRAM
DiagramTypes.UML_COMPONENT_DIAGRAM
DiagramTypes.UML_DEPLOYMENT_DIAGRAM
DiagramTypes.UML_PROFILE_DIAGRAM
DiagramTypes.UML_COMPOSITE_STRUCTURE_DIAGRAM
-