Java 类org.eclipse.swt.dnd.RTFTransfer 实例源码

项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
Transfer getTransferType(String mime) {
    if (mime.equals("text/plain")) {
      return TextTransfer.getInstance();
    }
    if (mime.equals("text/rtf")) {
      return RTFTransfer.getInstance();
    }
    if (mime.equals("text/html")) {
      return HTMLTransfer.getInstance();
    }
    if (mime.equals("text/uri-list")) {
      return URLTransfer.getInstance();
    }
    if (mime.equals("application/x-java-rawimage")) {
      return ImageTransfer.getInstance();
    }
    if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) {
        return FileTransfer.getInstance();
    }
    return getCustomTransfer(mime);
}
项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
String getMime(Transfer transfer) {
    if (transfer.equals(TextTransfer.getInstance())) {
      return "text/plain";
    }
    if (transfer.equals(RTFTransfer.getInstance())) {
      return "text/rtf";
    } ;
    if (transfer.equals( HTMLTransfer.getInstance())) {
      return "text/html";
    }
    if (transfer.equals(URLTransfer.getInstance())) {
      return "text/uri-list";
    }
    if (transfer.equals( ImageTransfer.getInstance())) {
      return "application/x-java-rawimage";
    }
    if (transfer.equals(FileTransfer.getInstance())) {
      return "application/x-java-file-list";
    }
    if (transfer instanceof CustomTransfer) {
      return ((CustomTransfer)transfer).getMime();
    }
    return null;
}
项目:JXTN    文件:FXCanvas.java   
Transfer getTransferType(String mime) {
    if (mime.equals("text/plain")) return TextTransfer.getInstance();
    if (mime.equals("text/rtf")) return RTFTransfer.getInstance();
    if (mime.equals("text/html")) return HTMLTransfer.getInstance();
    if (mime.equals("text/uri-list")) return URLTransfer.getInstance();
    if (mime.equals("application/x-java-rawimage")) return ImageTransfer.getInstance();
    if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) {
        return FileTransfer.getInstance();
    }
    return getCustomTransfer(mime);
}
项目:JXTN    文件:FXCanvas.java   
String getMime(Transfer transfer) {
    if (transfer.equals(TextTransfer.getInstance())) return "text/plain";
    if (transfer.equals(RTFTransfer.getInstance())) return "text/rtf"; ;
    if (transfer.equals( HTMLTransfer.getInstance())) return "text/html";
    if (transfer.equals(URLTransfer.getInstance())) return "text/uri-list";
    if (transfer.equals( ImageTransfer.getInstance())) return "application/x-java-rawimage";
    if (transfer.equals(FileTransfer.getInstance())) return "application/x-java-file-list";
    if (transfer instanceof CustomTransfer) return ((CustomTransfer)transfer).getMime();
    return null;
}
项目:birt    文件:TextEditor.java   
private void pasteClipboard( )
{
    Clipboard cb = new Clipboard( Display.getCurrent( ) );
    // TransferData[] types = cb.getAvailableTypes( );
    RTFTransfer rtfTransfer = RTFTransfer.getInstance( );
    Object contents = cb.getContents( rtfTransfer );
    // textEditor.paste( );
    if ( contents != null )
    {
        RTFHTMLHandler handler = new RTFHTMLHandler( );
        try
        {
            RTFParser.parse( contents.toString( ), handler );
            textEditor.insert( handler.toHTML( ) );
            return;
        }
        catch ( Exception e1 )
        {
        }
    }
    else
    {
        HTMLTransfer htmlTransfer = HTMLTransfer.getInstance( );
        contents = cb.getContents( htmlTransfer );
        if ( contents != null )
        {
            textEditor.insert( contents.toString( ) );
            return;
        }
    }

    TextTransfer plainTextTransfer = TextTransfer.getInstance( );
    String text = (String) cb.getContents( plainTextTransfer, DND.CLIPBOARD );
    textEditor.insert( text );
}
项目:Eclipse-Postfix-Code-Completion    文件:ClipboardOperationAction.java   
private void doCutCopyWithImportsOperation() {
    ITextEditor editor= getTextEditor();
    ITypeRoot inputElement= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
    ISelection selection= editor.getSelectionProvider().getSelection();

    Object clipboardData= null;
    if (inputElement != null && selection instanceof ITextSelection && !selection.isEmpty()) {
        ITextSelection textSelection= (ITextSelection) selection;
        if (isNonTrivialSelection(textSelection)) {
            clipboardData= getClipboardData(inputElement, textSelection.getOffset(), textSelection.getLength());
        }
    }

    fOperationTarget.doOperation(fOperationCode);

    if (clipboardData != null) {
        /*
         * We currently make assumptions about what the styled text widget sets,
         * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=61876
         */
        Clipboard clipboard= new Clipboard(getDisplay());
        try {
            Object textData= clipboard.getContents(TextTransfer.getInstance());
            /*
             * Don't add if we didn't get any text data from the clipboard, see:
             * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=70077
             * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=200743
             */
            if (textData == null)
                return;

            ArrayList<Object> datas= new ArrayList<Object>(3);
            ArrayList<ByteArrayTransfer> transfers= new ArrayList<ByteArrayTransfer>(3);
            datas.add(textData);
            transfers.add(TextTransfer.getInstance());

            Object rtfData= clipboard.getContents(RTFTransfer.getInstance());
            if (rtfData != null) {
                datas.add(rtfData);
                transfers.add(RTFTransfer.getInstance());
            }

            datas.add(clipboardData);
            transfers.add(fgTransferInstance);

            Transfer[] dataTypes= transfers.toArray(new Transfer[transfers.size()]);
            Object[] data= datas.toArray();
            setClipboardContents(clipboard, data, dataTypes);
        } finally {
            clipboard.dispose();
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClipboardOperationAction.java   
private void doCutCopyWithImportsOperation() {
    ITextEditor editor= getTextEditor();
    ITypeRoot inputElement= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
    ISelection selection= editor.getSelectionProvider().getSelection();

    Object clipboardData= null;
    if (inputElement != null && selection instanceof ITextSelection && !selection.isEmpty()) {
        ITextSelection textSelection= (ITextSelection) selection;
        if (isNonTrivialSelection(textSelection)) {
            clipboardData= getClipboardData(inputElement, textSelection.getOffset(), textSelection.getLength());
        }
    }

    fOperationTarget.doOperation(fOperationCode);

    if (clipboardData != null) {
        /*
         * We currently make assumptions about what the styled text widget sets,
         * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=61876
         */
        Clipboard clipboard= new Clipboard(getDisplay());
        try {
            Object textData= clipboard.getContents(TextTransfer.getInstance());
            /*
             * Don't add if we didn't get any text data from the clipboard, see:
             * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=70077
             * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=200743
             */
            if (textData == null)
                return;

            ArrayList<Object> datas= new ArrayList<Object>(3);
            ArrayList<ByteArrayTransfer> transfers= new ArrayList<ByteArrayTransfer>(3);
            datas.add(textData);
            transfers.add(TextTransfer.getInstance());

            Object rtfData= clipboard.getContents(RTFTransfer.getInstance());
            if (rtfData != null) {
                datas.add(rtfData);
                transfers.add(RTFTransfer.getInstance());
            }

            datas.add(clipboardData);
            transfers.add(fgTransferInstance);

            Transfer[] dataTypes= transfers.toArray(new Transfer[transfers.size()]);
            Object[] data= datas.toArray();
            setClipboardContents(clipboard, data, dataTypes);
        } finally {
            clipboard.dispose();
        }
    }
}