@OpenApiAll
public static final class Refactoring.RelationReconnecting
extends java.lang.Object
reconnectRelationForSelection(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. ListtargetElements = ...; // 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 and Description |
---|
RelationReconnecting() |
Modifier and Type | Method and Description |
---|---|
static Element |
reconnectRelationForSelection(java.util.List<Element> targetElements,
boolean incoming)
Reconnects one relation so that it skips selected part of the model.
|
@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.
Setting incoming = false
will change client point of the outgoing relation to the client point of the incoming relation.
targetElements
- list of elements that specifies selected part of the modelincoming
- should incoming or outgoing relation be reconnectedReadOnlyElementException
- 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.