Class ModelClipboard
java.lang.Object
org.eclipse.graphiti.ui.internal.util.clipboard.ModelClipboard
Provides a clipboard-like storage of EMF-related data based on SWT
Clipboard.-
Method Summary
Modifier and TypeMethodDescriptionCollection<org.eclipse.emf.ecore.EObject>duplicateAndPaste(Object target, org.eclipse.emf.transaction.TransactionalEditingDomain transactionalEditingDomain) Duplicates the clipboard's content using EMF's deep copy service.org.eclipse.emf.ecore.EObject[]getContentAsEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) Returns the SWTClipboardcontent in form ofEObjects.static ModelClipboardbooleanisCompositionAllowed(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EObject[] objects) Answers whether at least one of the given objects can be aggregated below the given parent as composite children.voidsetContent(org.eclipse.emf.ecore.EObject[] objects) Sets the content of theClipboardand deletes all previous data.toString()
-
Method Details
-
getDefault
- Returns:
- the default
ModelClipboardinstance to represent a globalModelClipboardto the user, which is connected to the SWTClipboard.
-
setContent
Sets the content of theClipboardand deletes all previous data. Must be called in the UI thread.- Parameters:
objects- theEObjectobjectsto store- Throws:
IllegalStateException- if not called from UI threadIllegalArgumentException- ifobjectsparameter is null
-
getContentAsEObjects
public org.eclipse.emf.ecore.EObject[] getContentAsEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws IllegalStateException Returns the SWTClipboardcontent in form ofEObjects.- Parameters:
resourceSet- the ResourceSet to resolve the stored URI information- Returns:
- the content as live objects
- Throws:
IllegalStateException- if not called from UI threadIllegalArgumentException- ifresourceSetparameter is null
-
isCompositionAllowed
public boolean isCompositionAllowed(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EObject[] objects) Answers whether at least one of the given objects can be aggregated below the given parent as composite children. This generic implementation considers type compatibility and cardinalities but no additional domain specific constraints.- Parameters:
parent- the composite parentobjects- the objects to check- Returns:
trueif at least one object may be a composite child ofparent
-
duplicateAndPaste
public Collection<org.eclipse.emf.ecore.EObject> duplicateAndPaste(Object target, org.eclipse.emf.transaction.TransactionalEditingDomain transactionalEditingDomain) throws IllegalStateException Duplicates the clipboard's content using EMF's deep copy service. Note that only elements from the content that areEObjects are considered, pureEObjects like packages cannot be duplicated.- Parameters:
target- an object acting as composite parent for the copies.nullif the copied elements should be top-level elements.transactionalEditingDomain- the TransactionalEditingDomain to write the copies into. Must not benullnor dead.- Returns:
- the copy result or
nullin case of an empty clipboard - Throws:
IllegalStateException- if not called from UI threadIllegalArgumentException- iftransactionalEditingDomainparameter is nullIllegalArgumentException- iftransactionalEditingDomainparameter is not equal to the TransactionalEditingDomain oftargetparameter- See Also:
-
toString
-