@OpenApiAll
public class CopyPasting
extends java.lang.Object
Provides API for copy-pasting elements in the model and symbol styles in diagrams.
You can copy model elements and symbols either to another location in the same project or to another project. This must be done in the same session. There are two modes of making copies of model elements:
Element element = ...; // Element to copy/paste. Element parent = ...; // Parent to which the element has to be pasted: either the same project or another project. SessionManager sessionManager = SessionManager.getInstance(); sessionManager.createSession("Clone"); // 3rd parameter indicates whether element name uniqueness should be preserved in the parent. CopyPasting.copyPasteElement(element, parent, true); sessionManager.closeSession();
List elements = ...; // Elements to copy/paste. List views = ...; // Symbols to copy/paste. Element parent = ...; // Parent to which elements should be pasted: either the same project or another project. BaseElement symbolParent = ...; // Parent to which symbols should be pasted. SessionManager sessionManager = SessionManager.getInstance(); sessionManager.createSession("Clone"); // 4th parameter indicates whether deep or shallow copy is applied. // 5th parameter indicates whether element name uniqueness should be preserved in the parent. List baseElements = CopyPasting.copyPasteElements(views, parent, symbolParent, true, true); sessionManager.closeSession();
PresentationElement source = ...; // Symbol with symbol properties (style) to copy PresentationElement target = ...; // Symbol to paste style on SessionManager sessionManager = SessionManager.getInstance(); sessionManager.createSession("Clone Symbol Style"); CopyPasting.copyPasteSymbolsStyle(source, target) sessionManager.closeSession();
PresentationElement source = ...; // Symbol with symbol properties (style) to copy Collectiontargets = ...; // Symbols to paste style on SessionManager sessionManager = SessionManager.getInstance(); sessionManager.createSession("Clone Symbol Style"); CopyPasting.copyPasteSymbolsStyle(source, targets) sessionManager.closeSession();
BaseElement
,
Element
,
PresentationElement
,
SessionManager
Constructor and Description |
---|
CopyPasting() |
Modifier and Type | Method and Description |
---|---|
static Element |
copyPasteElement(Element elementToCopy,
Element parent)
Makes a copy of the specified element and places it under the parent (namespace).
|
static Element |
copyPasteElement(Element elementToCopy,
Element parent,
boolean increaseElementNames)
Makes a copy of the specified element and places it under the parent (namespace).
|
static java.util.List<BaseElement> |
copyPasteElements(java.util.Collection<? extends BaseElement> objectsToCopy,
BaseElement dataParent,
BaseElement viewParent,
boolean withNewData,
boolean increaseElementNames)
Clones given objects (model elements or symbols) and establishes correct relationships.
|
static java.util.List |
copyPasteElements(java.util.List<? extends Element> elementsToCopy,
Element parent)
Makes a copy of specified elements and places them under the given parent (namespace).
|
static java.util.List |
copyPasteElements(java.util.List<? extends Element> elementsToCopy,
Element parent,
boolean increaseElementNames)
Makes a copy of specified elements and places them under the given parent (namespace).
|
static void |
copyPasteSymbolsStyle(java.util.Collection<PresentationElement> sourceSymbols,
java.util.Collection<PresentationElement> targetSymbols)
Copies symbol style from one of the source symbols to target symbols.
|
static void |
copyPasteSymbolsStyle(PresentationElement sourceSymbol,
java.util.Collection<PresentationElement> targetSymbols)
Copies symbol style from provided source symbol and pastes it on each target symbol.
|
static void |
copyPasteSymbolsStyle(PresentationElement sourceSymbol,
PresentationElement targetSymbol)
Copies symbol style from provided source symbol and pastes on target symbol.
|
@CheckForNull public static Element copyPasteElement(Element elementToCopy, Element parent)
SessionManager
.elementToCopy
- element to copy.parent
- owner to which to add copied element.@CheckForNull public static Element copyPasteElement(Element elementToCopy, Element parent, boolean increaseElementNames)
SessionManager
.elementToCopy
- element to copy.parent
- owner to which to add copied element.increaseElementNames
- indicates if element names should be increased in given namespace to avoid duplication.public static java.util.List copyPasteElements(java.util.List<? extends Element> elementsToCopy, Element parent)
SessionManager
.elementsToCopy
- collection of Element} objects to be copied.parent
- parent where objects should be placed.public static java.util.List copyPasteElements(java.util.List<? extends Element> elementsToCopy, Element parent, boolean increaseElementNames)
SessionManager
.elementsToCopy
- collection of Element} objects to be copied.parent
- parent where objects should be placed.increaseElementNames
- indicates if element names should be increased in given namespace to avoid duplication.public static java.util.List<BaseElement> copyPasteElements(java.util.Collection<? extends BaseElement> objectsToCopy, @CheckForNull BaseElement dataParent, BaseElement viewParent, boolean withNewData, boolean increaseElementNames)
objectsToCopy
- objects to copy.dataParent
- data parent.viewParent
- parent of symbols.withNewData
- indicates whether pasting should be done with new data (deep or shallow copy).increaseElementNames
- indicates whether elements names should be increased.public static void copyPasteSymbolsStyle(PresentationElement sourceSymbol, PresentationElement targetSymbol) throws ReadOnlyElementException
SessionManager
.sourceSymbol
- symbol to copy style fromtargetSymbol
- symbol to paste style onReadOnlyElementException
- when target symbol is read only or symbol's owner is read only.public static void copyPasteSymbolsStyle(PresentationElement sourceSymbol, java.util.Collection<PresentationElement> targetSymbols) throws ReadOnlyElementException
SessionManager
.sourceSymbol
- symbol to copy style fromtargetSymbols
- symbols to paste style onReadOnlyElementException
- when any of the target symbols is read only or symbol's owner is read only.public static void copyPasteSymbolsStyle(java.util.Collection<PresentationElement> sourceSymbols, java.util.Collection<PresentationElement> targetSymbols) throws ReadOnlyElementException
SessionManager
.sourceSymbols
- symbols to copy style fromtargetSymbols
- symbols to paste style onReadOnlyElementException
- when any of the target symbols is read only or symbol's owner is read only.