org.eclipse.swt.dnd.HTMLTransfer Java Examples
The following examples show how to use
org.eclipse.swt.dnd.HTMLTransfer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrowserManager.java From Rel with Apache License 2.0 | 5 votes |
public static void copyToClipboard(String html) { if (html == null || html.length() == 0) return; html = html.replace("<table", "<table border=\"1\""); Clipboard clipboard = new Clipboard(Display.getCurrent()); TextTransfer textTransfer = TextTransfer.getInstance(); HTMLTransfer htmlTransfer = HTMLTransfer.getInstance(); Transfer[] transfers = new Transfer[] {textTransfer, htmlTransfer}; Object[] data = new Object[] {html, html}; clipboard.setContents(data, transfers); clipboard.dispose(); }
Example #2
Source File: DBrowser.java From Rel with Apache License 2.0 | 5 votes |
private static boolean isThereSomethingToPaste() { Clipboard clipboard = new Clipboard(Display.getCurrent()); try { TextTransfer textTransfer = TextTransfer.getInstance(); HTMLTransfer htmlTransfer = HTMLTransfer.getInstance(); String textData = (String)clipboard.getContents(textTransfer); String htmlData = (String)clipboard.getContents(htmlTransfer); return (textData != null && textData.length() > 0) || (htmlData != null && htmlData.length() > 0); } finally { clipboard.dispose(); } }
Example #3
Source File: TextEditor.java From birt with Eclipse Public License 1.0 | 5 votes |
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 ); }