Class ModelClipboard
- java.lang.Object
-
- org.eclipse.graphiti.ui.internal.util.clipboard.ModelClipboard
-
public final class ModelClipboard extends java.lang.ObjectProvides 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 SWTClipboardcontent in form ofEObjects.static ModelClipboardgetDefault()booleanisCompositionAllowed(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.java.lang.StringtoString()
-
-
-
Method Detail
-
getDefault
public static ModelClipboard getDefault()
- Returns:
- the default
ModelClipboardinstance to represent a globalModelClipboardto the user, which is connected to the SWTClipboard.
-
setContent
public void setContent(org.eclipse.emf.ecore.EObject[] objects) throws java.lang.IllegalStateExceptionSets the content of theClipboardand deletes all previous data. Must be called in the UI thread.- Parameters:
objects- theEObjectobjectsto store- Throws:
java.lang.IllegalStateException- if not called from UI threadjava.lang.IllegalArgumentException- ifobjectsparameter is null
-
getContentAsEObjects
public org.eclipse.emf.ecore.EObject[] getContentAsEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.lang.IllegalStateExceptionReturns the SWTClipboardcontent in form ofEObjects.- 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- 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 java.util.Collection<org.eclipse.emf.ecore.EObject> duplicateAndPaste(java.lang.Object target, org.eclipse.emf.transaction.TransactionalEditingDomain transactionalEditingDomain) throws java.lang.IllegalStateExceptionDuplicates 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:
java.lang.IllegalStateException- if not called from UI threadjava.lang.IllegalArgumentException- iftransactionalEditingDomainparameter is nulljava.lang.IllegalArgumentException- iftransactionalEditingDomainparameter is not equal to the TransactionalEditingDomain oftargetparameter- See Also:
isCompositionAllowed(EObject, EObject[]),getContentAsEObjects(ResourceSet)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-