Class ModelElementsManager
- java.lang.Object
-
- com.nomagic.magicdraw.openapi.uml.ModelElementsManager
-
@OpenApiAll public final class ModelElementsManager extends java.lang.Object
The utility class for ModelElements adding, removing and moving to other parents. Also it helps to create all 7 types of diagrams. Works together withSessionManager
. This manager can be used only if some session was created with SessionManager. See code sample in SessionManager description for more details.- See Also:
SessionManager
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addElement(Element element, Element parent)
Adds given element into the given parent.Diagram
createDiagram(java.lang.String type, Namespace parent)
Creates new Diagram of given type.Diagram
createDiagram(java.lang.String type, Namespace parent, boolean openDiagram, boolean openInActiveTab)
Creates new Diagram of given type.static ModelElementsManager
getInstance()
Returns an instance of this manager.void
moveElement(Element element, Element parent)
Moves given element from current parent into the given one.void
removeElement(Element element)
Removes given element from the model.
-
-
-
Method Detail
-
getInstance
public static ModelElementsManager getInstance()
Returns an instance of this manager.- Returns:
- instance of this manager.Pro
-
addElement
public void addElement(Element element, Element parent) throws ReadOnlyElementException
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:
java.lang.IllegalStateException
- if session is not created with SessionManagerjava.lang.IllegalArgumentException
- 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:
SessionManager.createSession(java.lang.String)
-
moveElement
public void moveElement(Element element, Element parent) throws ReadOnlyElementException
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:
java.lang.IllegalStateException
- if session is not created with SessionManagerjava.lang.IllegalArgumentException
- 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:
SessionManager.createSession(java.lang.String)
-
removeElement
public void removeElement(Element element) throws ReadOnlyElementException
Removes given element from the model.- Parameters:
element
- the given ModelElement to remove.- Throws:
java.lang.IllegalStateException
- if session is not created with SessionManager.java.lang.IllegalArgumentException
- if given element is null.ReadOnlyElementException
- if given element is not editable(read only).- See Also:
SessionManager.createSession(java.lang.String)
-
createDiagram
public Diagram createDiagram(java.lang.String type, Namespace parent) 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 owner- Returns:
- The created diagram.
- Throws:
java.lang.IllegalStateException
- if session is not created with SessionManagerjava.lang.IllegalArgumentException
- 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(java.lang.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:
java.lang.IllegalStateException
- if session is not created with SessionManagerjava.lang.IllegalArgumentException
- 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
-
-