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 SWTClipboard
content in form ofEObject
s.static ModelClipboard
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.void
setContent
(org.eclipse.emf.ecore.EObject[] objects) Sets the content of theClipboard
and deletes all previous data.toString()
-
Method Details
-
getDefault
- Returns:
- the default
ModelClipboard
instance to represent a globalModelClipboard
to the user, which is connected to the SWTClipboard
.
-
setContent
Sets the content of theClipboard
and deletes all previous data. Must be called in the UI thread.- Parameters:
objects
- theEObject
objects
to store- Throws:
IllegalStateException
- if not called from UI threadIllegalArgumentException
- ifobjects
parameter is null
-
getContentAsEObjects
public org.eclipse.emf.ecore.EObject[] getContentAsEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws IllegalStateException Returns the SWTClipboard
content in form ofEObject
s.- Parameters:
resourceSet
- the ResourceSet to resolve the stored URI information- Returns:
- the content as live objects
- Throws:
IllegalStateException
- if not called from UI threadIllegalArgumentException
- ifresourceSet
parameter 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:
true
if 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 areEObject
s are considered, pureEObject
s like packages cannot be duplicated.- Parameters:
target
- an object acting as composite parent for the copies.null
if the copied elements should be top-level elements.transactionalEditingDomain
- the TransactionalEditingDomain to write the copies into. Must not benull
nor dead.- Returns:
- the copy result or
null
in case of an empty clipboard - Throws:
IllegalStateException
- if not called from UI threadIllegalArgumentException
- iftransactionalEditingDomain
parameter is nullIllegalArgumentException
- iftransactionalEditingDomain
parameter is not equal to the TransactionalEditingDomain oftarget
parameter- See Also:
-
toString
-