Class ModelClipboard


  • public final class ModelClipboard
    extends java.lang.Object
    Provides a clipboard-like storage of EMF-related data based on SWT Clipboard.
    • 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 SWT Clipboard content in form of EObjects.
      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 the Clipboard and deletes all previous data.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • setContent

        public void setContent​(org.eclipse.emf.ecore.EObject[] objects)
                        throws java.lang.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:
        java.lang.IllegalStateException - if not called from UI thread
        java.lang.IllegalArgumentException - if objects parameter is null
      • getContentAsEObjects

        public org.eclipse.emf.ecore.EObject[] getContentAsEObjects​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
                                                             throws java.lang.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:
        java.lang.IllegalStateException - if not called from UI thread
        java.lang.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 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 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:
        java.lang.IllegalStateException - if not called from UI thread
        java.lang.IllegalArgumentException - if transactionalEditingDomain parameter is null
        java.lang.IllegalArgumentException - if transactionalEditingDomain parameter is not equal to the TransactionalEditingDomain of target parameter
        See Also:
        isCompositionAllowed(EObject, EObject[]), getContentAsEObjects(ResourceSet)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object