Class ModelClipboard
- java.lang.Object
-
- org.eclipse.graphiti.ui.internal.util.clipboard.ModelClipboard
-
public final class ModelClipboard extends java.lang.Object
Provides a clipboard-like storage of EMF-related data based on SWTClipboard
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<org.eclipse.emf.ecore.EObject>
duplicateAndPaste(java.lang.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
getDefault()
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.java.lang.String
toString()
-
-
-
Method Detail
-
getDefault
public static ModelClipboard getDefault()
- Returns:
- the default
ModelClipboard
instance to represent a globalModelClipboard
to the user, which is connected to the SWTClipboard
.
-
setContent
public void setContent(org.eclipse.emf.ecore.EObject[] objects) throws java.lang.IllegalStateException
Sets the content of theClipboard
and deletes all previous data. Must be called in the UI thread.- Parameters:
objects
- theEObject
objects
to store- Throws:
java.lang.IllegalStateException
- if not called from UI threadjava.lang.IllegalArgumentException
- ifobjects
parameter is null
-
getContentAsEObjects
public org.eclipse.emf.ecore.EObject[] getContentAsEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.lang.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:
java.lang.IllegalStateException
- if not called from UI threadjava.lang.IllegalArgumentException
- 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 java.util.Collection<org.eclipse.emf.ecore.EObject> duplicateAndPaste(java.lang.Object target, org.eclipse.emf.transaction.TransactionalEditingDomain transactionalEditingDomain) throws java.lang.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:
java.lang.IllegalStateException
- if not called from UI threadjava.lang.IllegalArgumentException
- iftransactionalEditingDomain
parameter is nulljava.lang.IllegalArgumentException
- iftransactionalEditingDomain
parameter is not equal to the TransactionalEditingDomain oftarget
parameter- See Also:
isCompositionAllowed(EObject, EObject[])
,getContentAsEObjects(ResourceSet)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-