Interface ClipboardFragmentInformation


  • @API(type=NOT_EXTENDABLE,
         src=PUBLIC)
    public interface ClipboardFragmentInformation
    Provides information about a fragment in the clipboard. The fragment received in the callback can either be directly processed or a new fragment can be set instead. An easy way to modify the fragment XML content is like this:
      public void process(ClipboardFragmentInformation fragmentInformation) {
       AuthorDocumentFragment frag = fragmentInformation.getFragment();
       try {
         String xmlContent = authorAccess.getDocumentController().serializeFragmentToXML(frag);
         //Modify the XML content here.....
         
         //Re-create a new fragment from the XML
         AuthorDocumentFragment newFragment = authorAccess.getDocumentController().createNewDocumentFragmentInContext(xmlContent, authorAccess.getEditorAccess().getCaretOffset());
         
         fragmentInformation.setFragment(newFragment);
       } catch (BadLocationException e) {
         e.printStackTrace();
       } catch (AuthorOperationException e) {
         e.printStackTrace();
       }
     }
    Since:
    12.2
    • Method Detail

      • getClipboardObjectID

        java.lang.String getClipboardObjectID()
        Get an unique ID of this object taken from the clipboard. For example if multiple pastes are made with same content, the same object ID is returned.
        Returns:
        An unique ID of this object taken from the clipboard.
      • getFragmentOriginalLocation

        @Deprecated
        java.lang.String getFragmentOriginalLocation()
        Deprecated.
        from Oxygen 24 because it modifies the system ID at consecutive Paste, setting the systemID as current editor location.
        Get the URL of the file from which the fragment was copied. If the fragment was pasted from outside of Oxygen, the original location is null.
        Returns:
        The URL of the file from which the fragment was copied. If the fragment was pasted from outside of Oxygen, the original location is null.
      • getFragment

        AuthorDocumentFragment getFragment()
        Get the fragment which will be pasted/dropped.
        Returns:
        The fragment which will be pasted/dropped.
      • setFragment

        void setFragment​(AuthorDocumentFragment newFragment)
        Set a new fragment replacing the original one which will be pasted/dropped.
        Parameters:
        newFragment - The fragment which will be pasted/dropped.
        Since:
        13
      • getOriginalLocation

        java.lang.String getOriginalLocation()
        The URL of the file from which the fragment was copied. If the fragment was pasted from outside of Oxygen, the original location is null.
        Returns:
        URL of the file from which the fragment was copied.
        Since:
        24.0
      • getLocationOfLastPaste

        java.lang.String getLocationOfLastPaste()
        Get the fragment original location or the location where it was last pasted. Can be null
        Returns:
        the fragment original location or the location where it was last pasted.
        Since:
        24.0