Java Code Examples for org.eclipse.swt.dnd.TextTransfer#getInstance()
The following examples show how to use
org.eclipse.swt.dnd.TextTransfer#getInstance() .
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: SinkView.java From lapse-plus with GNU General Public License v3.0 | 6 votes |
public void run() { StringBuffer buf = new StringBuffer(); addCalls(viewer.getTable().getSelection(), buf); TextTransfer plainTextTransfer = TextTransfer.getInstance(); try { fClipboard.setContents(new String[]{convertLineTerminators(buf.toString())}, new Transfer[]{plainTextTransfer}); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog .openQuestion(fView.getViewSite().getShell(), ("CopyCallHierarchyAction.problem"), ("CopyCallHierarchyAction.clipboard_busy"))) { run(); } } }
Example 2
Source File: LapseView.java From lapse-plus with GNU General Public License v3.0 | 6 votes |
public void run() { StringBuffer buf= new StringBuffer(); addCalls(fViewer.getTree().getSelection()[0], 0, buf);//we get the node selected in the tree TextTransfer plainTextTransfer = TextTransfer.getInstance();//for converting plain text in a String into Platform specific representation try{ fClipboard.setContents( new String[]{ convertLineTerminators(buf.toString()) }, new Transfer[]{ plainTextTransfer }); } catch (SWTError e){ if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog.openQuestion(fView.getViewSite().getShell(), ("CopyCallHierarchyAction.problem"), ("CopyCallHierarchyAction.clipboard_busy")) ) { run(); } } }
Example 3
Source File: SourceView.java From lapse-plus with GNU General Public License v3.0 | 6 votes |
public void run() { StringBuffer buf = new StringBuffer(); addCalls(viewer.getTable().getSelection(), buf); TextTransfer plainTextTransfer = TextTransfer.getInstance(); try{ fClipboard.setContents( new String[]{ convertLineTerminators(buf.toString()) }, new Transfer[]{ plainTextTransfer }); } catch (SWTError e){ if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog.openQuestion(fView.getViewSite().getShell(), ("CopyCallHierarchyAction.problem"), ("CopyCallHierarchyAction.clipboard_busy")) ) { run(); } } }
Example 4
Source File: CopyDataToClipboardSerializer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void serialize() { final Clipboard clipboard = command.getClipboard(); final String cellDelimeter = command.getCellDelimeter(); final String rowDelimeter = command.getRowDelimeter(); final TextTransfer textTransfer = TextTransfer.getInstance(); final StringBuilder textData = new StringBuilder(); int currentRow = 0; for (LayerCell[] cells : copiedCells) { int currentCell = 0; for (LayerCell cell : cells) { final String delimeter = ++currentCell < cells.length ? cellDelimeter : ""; if (cell != null) { textData.append(cell.getDataValue() + delimeter); } else { textData.append(delimeter); } } if (++currentRow < copiedCells.length) { textData.append(rowDelimeter); } } clipboard.setContents(new Object[]{textData.toString()}, new Transfer[]{textTransfer}); }
Example 5
Source File: LocationCopyAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void run() { IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection(); StringBuffer buf= new StringBuffer(); for (Iterator<?> iterator= selection.iterator(); iterator.hasNext();) { CallLocation location= (CallLocation) iterator.next(); buf.append(location.getLineNumber()).append('\t').append(location.getCallText()); buf.append('\n'); } TextTransfer plainTextTransfer = TextTransfer.getInstance(); try { fClipboard.setContents( new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) }, new Transfer[]{ plainTextTransfer }); } catch (SWTError e){ if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy)) run(); } }
Example 6
Source File: CopyCallHierarchyAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void run() { StringBuffer buf= new StringBuffer(); addCalls(fViewer.getTree().getSelection()[0], 0, buf); TextTransfer plainTextTransfer= TextTransfer.getInstance(); try { fClipboard.setContents( new String[] { convertLineTerminators(buf.toString()) }, new Transfer[] { plainTextTransfer }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e; if (MessageDialog.openQuestion(fView.getViewSite().getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy)) run(); } }
Example 7
Source File: GuiResource.java From hop with Apache License 2.0 | 5 votes |
public void toClipboard( String cliptext ) { if ( cliptext == null ) { return; } getNewClipboard(); TextTransfer tran = TextTransfer.getInstance(); clipboard.setContents( new String[] { cliptext }, new Transfer[] { tran } ); }
Example 8
Source File: StyledTextComp.java From hop with Apache License 2.0 | 5 votes |
private boolean checkPaste() { try { Clipboard clipboard = new Clipboard( xParent.getDisplay() ); TextTransfer transfer = TextTransfer.getInstance(); String text = (String) clipboard.getContents( transfer ); if ( text != null && text.length() > 0 ) { return true; } else { return false; } } catch ( Exception e ) { return false; } }
Example 9
Source File: GridCopyEnable.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
void copy() { if (focusContent == null || focusContent.equals("")) { return; } if (selection.x != selection.y) { String plainText = focusContent.substring(selection.x, selection.y); Object[] data = new Object[] { plainText }; TextTransfer plainTextTransfer = TextTransfer.getInstance(); Transfer[] types = new Transfer[] { plainTextTransfer }; clipboard.setContents(data, types); } }
Example 10
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 ); }
Example 11
Source File: PasteAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected final String getClipboardText(TransferData[] availableDataTypes) { Transfer transfer= TextTransfer.getInstance(); if (isAvailable(transfer, availableDataTypes)) { return (String) getContents(fClipboard2, transfer, getShell()); } return null; }
Example 12
Source File: Utils.java From EasyShell with Eclipse Public License 2.0 | 5 votes |
public static void copyToClipboard(String cmdAll) { Clipboard clipboard = new Clipboard(Display.getCurrent()); TextTransfer textTransfer = TextTransfer.getInstance(); Transfer[] transfers = new Transfer[]{textTransfer}; Object[] data = new Object[]{cmdAll}; clipboard.setContents(data, transfers); clipboard.dispose(); }
Example 13
Source File: KillRing.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Get the text from the system clipboard * * @return the system clipboard content as a String */ public String getClipboardText() { Clipboard clipboard = new Clipboard(Display.getCurrent()); TextTransfer plainTextTransfer = TextTransfer.getInstance(); String cliptxt = (String)clipboard.getContents(plainTextTransfer, DND.CLIPBOARD); clipboard.dispose(); return cliptxt; }
Example 14
Source File: Clipboards.java From offspring with MIT License | 5 votes |
public static void copy(Display display, String contents) { Clipboard clipboard = new Clipboard(display); TextTransfer textTransfer = TextTransfer.getInstance(); clipboard.setContents(new String[] { contents }, new Transfer[] { textTransfer }); clipboard.dispose(); }
Example 15
Source File: KillRing.java From e4macs with Eclipse Public License 1.0 | 4 votes |
public void setClipboardText(String text){ Clipboard clipboard = new Clipboard(Display.getCurrent()); TextTransfer plainTextTransfer = TextTransfer.getInstance(); clipboard.setContents(new Object[] {text},new Transfer[]{plainTextTransfer}); clipboard.dispose(); }
Example 16
Source File: LogContent.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
private void copyToClipboard(String text) { Clipboard clipboard = new Clipboard(getDisplay()); TextTransfer tt = TextTransfer.getInstance(); clipboard.setContents(new Object[] {text}, new Transfer[] {tt}); }
Example 17
Source File: TexOutlinePage.java From texlipse with Eclipse Public License 1.0 | 4 votes |
/** * Creates the control ie. creates all the stuff that matters and * is visible in the outline. * * Actions must be created before menus and toolbars. * * @param parent */ public void createControl(Composite parent) { super.createControl(parent); // create the context actions createActions(); // initialize the tree viewer TreeViewer viewer = getTreeViewer(); filter = new TexOutlineFilter(); viewer.setContentProvider(new TexContentProvider(filter)); viewer.setLabelProvider(new TexLabelProvider()); viewer.setComparer(new TexOutlineNodeComparer()); // get and apply the preferences this.getOutlinePreferences(); viewer.addFilter(filter); // set the selection listener viewer.addSelectionChangedListener(this); // enable drag'n'drop support TexOutlineDNDAdapter dndAdapter = new TexOutlineDNDAdapter(viewer, this); int ops = DND.DROP_COPY | DND.DROP_MOVE; Transfer[] transfers = new Transfer[] {TextTransfer.getInstance()}; viewer.addDragSupport(ops, transfers, dndAdapter); viewer.addDropSupport(ops, transfers, dndAdapter); // enable copy-paste initCopyPaste(viewer); // create the menu bar and the context menu createToolbar(); resetToolbarButtons(); createContextMenu(); // finally set the input if (this.input != null) { viewer.setInput(this.input.getRootNodes()); // set update button status and also the context actions outlineActions.get(ACTION_UPDATE).setEnabled(false); outlineActions.get(ACTION_COPY).setEnabled(true); outlineActions.get(ACTION_CUT).setEnabled(true); outlineActions.get(ACTION_PASTE).setEnabled(true); outlineActions.get(ACTION_DELETE).setEnabled(true); } }
Example 18
Source File: CommonDragAdapterAssistant.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public Transfer[] getSupportedTransferTypes () { return new Transfer[] { ItemTransfer.getInstance (), TextTransfer.getInstance (), URLTransfer.getInstance () }; }
Example 19
Source File: CommonDragAdapterAssistant.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public Transfer[] getSupportedTransferTypes () { return new Transfer[] { ItemTransfer.getInstance (), TextTransfer.getInstance (), URLTransfer.getInstance () }; }
Example 20
Source File: GuiResource.java From hop with Apache License 2.0 | 4 votes |
public String fromClipboard() { getNewClipboard(); TextTransfer tran = TextTransfer.getInstance(); return (String) clipboard.getContents( tran ); }