Class ModelClipboard

java.lang.Object
org.eclipse.graphiti.ui.internal.util.clipboard.ModelClipboard

public final class ModelClipboard extends Object
Provides a clipboard-like storage of EMF-related data based on SWT Clipboard.
  • Method Summary

    Modifier and Type
    Method
    Description
    Collection<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 SWT Clipboard content in form of EObjects.
     
    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 the Clipboard and deletes all previous data.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getDefault

      public static ModelClipboard getDefault()
      Returns:
      the default ModelClipboard instance to represent a global ModelClipboard to the user, which is connected to the SWT Clipboard.
    • setContent

      public void setContent(org.eclipse.emf.ecore.EObject[] objects) throws IllegalStateException
      Sets the content of the Clipboard and deletes all previous data. Must be called in the UI thread.
      Parameters:
      objects - the EObject objects to store
      Throws:
      IllegalStateException - if not called from UI thread
      IllegalArgumentException - if objects parameter is null
    • getContentAsEObjects

      public org.eclipse.emf.ecore.EObject[] getContentAsEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws IllegalStateException
      Returns the SWT Clipboard content in form of EObjects.
      Parameters:
      resourceSet - the ResourceSet to resolve the stored URI information
      Returns:
      the content as live objects
      Throws:
      IllegalStateException - if not called from UI thread
      IllegalArgumentException - if resourceSet 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 parent
      objects - the objects to check
      Returns:
      true if at least one object may be a composite child of parent
    • 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 are EObjects are considered, pure EObjects 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 be null nor dead.
      Returns:
      the copy result or null in case of an empty clipboard
      Throws:
      IllegalStateException - if not called from UI thread
      IllegalArgumentException - if transactionalEditingDomain parameter is null
      IllegalArgumentException - if transactionalEditingDomain parameter is not equal to the TransactionalEditingDomain of target parameter
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object