Class Refactoring.RelationReconnecting
- java.lang.Object
-
- com.nomagic.magicdraw.uml.Refactoring.RelationReconnecting
-
- Enclosing class:
- Refactoring
@OpenApiAll public static final class Refactoring.RelationReconnecting extends java.lang.Object
Reconnects one relation so that it skips selected part of the model. Useful when removing elements from model. For detailed explanation see description ofreconnectRelationForSelection(java.util.List<com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element>, boolean)
method. An example how to reconnect relations:// A list of elements that specifies consistent part of the model // i.e. model elements of selected presentation elements in a diagram. List
targetElements = ...; // Relationship reconnecting should be wrapped with session create/close calls. SessionManager sessionManager = SessionManager.getInstance(); sessionManager.createSession("Reconnect relation"); // Decide if incoming or outgoing relation should be reconnected. boolean incoming = ...; // Reconnect relation. Element relation = Refactoring.RelationReconnecting.reconnectRelationForSelection(targetElements, incoming); // Check result for null to see if any relation was reconnected. if (relation != null) { // relation was reconnected } // Close the session. sessionManager.closeSession();
-
-
Constructor Summary
Constructors Constructor Description RelationReconnecting()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Element
reconnectRelationForSelection(java.util.List<Element> targetElements, boolean incoming)
Reconnects one relation so that it skips selected part of the model.
-
-
-
Method Detail
-
reconnectRelationForSelection
@CheckForNull public static Element reconnectRelationForSelection(java.util.List<Element> targetElements, boolean incoming) throws ReadOnlyElementException, java.lang.IllegalArgumentException
Reconnects one relation so that it skips selected part of the model. Updates paths of reconnected relation to preserve previous form. Exactly one incoming relation and exactly one outgoing relation must exist for the given selection, or
IllegalArgumentException
exception will be thrown. These two relations may or may not be included in the selection.Incoming relation is a relation element that starts from a client element that is not among targeted elements, but targets a supplier element that is in the list of targeted elements. Outgoing relation is a relation element that targets supplier element that is not among targeted elements, but starts from a client element that is among targeted elements.
Setting
incoming = true
will change supplier point of the incoming relation to the supplier point of the outgoing relation. Settingincoming = false
will change client point of the outgoing relation to the client point of the incoming relation.- Parameters:
targetElements
- list of elements that specifies selected part of the modelincoming
- should incoming or outgoing relation be reconnected- Returns:
- reconnected relation or null, if no changes where made
- Throws:
ReadOnlyElementException
- when any of provided elements is read-onlyjava.lang.IllegalArgumentException
- when list of elements is empty or when count of incoming/outgoing relations is not one.
-
-