Class Refactoring.Moving

java.lang.Object
com.nomagic.magicdraw.uml.Refactoring.Moving
Enclosing class:
Refactoring

@OpenApiAll public static class Refactoring.Moving extends Object
Moves elements in model to a new owner element with or without connected relations An example how to move elements together with their relations:
 // Decide what elements needs to be moved and put them in a collection
 Collection elementsToMove = ...;

 // Define new owner to move elements (and relations) into
 Element newOwner = ...;

 // Element moving should be wrapped with session create/close calls.
 SessionManager sessionManager = SessionManager.getInstance();
 sessionManager.createSession("Move elements");

 // Move elements
 Refactoring.Moving.moveElementsWithRelations(elementsToMove, newOwner);

 // Close the session.
 sessionManager.closeSession();
 
  • Constructor Details

    • Moving

      public Moving()
  • Method Details

    • moveElements

      public static void moveElements(Collection<Element> elementsToMove, Element newOwner) throws ReadOnlyElementException
      Moves all elements to the new owner. Relations between moved elements are not moved.
      Parameters:
      elementsToMove - elements to move
      newOwner - new owner to move elements into
      Throws:
      ReadOnlyElementException - if newOwner cannot add children or any of moved elements is not editable
      IllegalArgumentException - if any of moved elements cannot be added into new owner
    • moveElementsWithRelations

      public static void moveElementsWithRelations(Collection<Element> elementsToMove, Element newOwner) throws ReadOnlyElementException
      Moves all elements to the new owner. Relation elements whose client is between moved elements are moved together. Read only relations are not moved. Not locked teamwork relations are locked automatically.
      Parameters:
      elementsToMove - elements to move
      newOwner - new owner to move elements into
      Throws:
      ReadOnlyElementException - if newOwner cannot add children or any of moved elements is not editable
      IllegalArgumentException - if any of moved elements cannot be added into new owner