Search in sources :

Example 31 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project janrufmonitor by tbrandt77.

the class ClipboardAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Object o = selection.getFirstElement();
            ITableCellRenderer tcr = RendererRegistry.getInstance().getRenderer("number");
            if (tcr != null) {
                tcr.updateData(o);
                Clipboard cb = new Clipboard(DisplayManager.getDefaultDisplay());
                String textData = tcr.renderAsText();
                TextTransfer textTransfer = TextTransfer.getInstance();
                cb.setContents(new Object[] { (textData != null ? textData : "") }, new Transfer[] { textTransfer });
            }
        }
    }
}
Also used : ITableCellRenderer(de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 32 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project janrufmonitor by tbrandt77.

the class ClipboardAddressAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Object o = selection.getFirstElement();
            ITableCellRenderer tcr = RendererRegistry.getInstance().getRenderer("name");
            if (tcr != null) {
                tcr.updateData(o);
                Clipboard cb = new Clipboard(DisplayManager.getDefaultDisplay());
                String textData = tcr.renderAsText();
                TextTransfer textTransfer = TextTransfer.getInstance();
                cb.setContents(new Object[] { (textData != null ? textData : "") }, new Transfer[] { textTransfer });
            }
        }
    }
}
Also used : ITableCellRenderer(de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 33 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project janrufmonitor by tbrandt77.

the class NotesClipboardAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Object o = selection.getFirstElement();
            ITableCellRenderer tcr = RendererRegistry.getInstance().getRenderer("notes");
            if (tcr != null) {
                tcr.updateData(o);
                Clipboard cb = new Clipboard(DisplayManager.getDefaultDisplay());
                String textData = tcr.renderAsText();
                TextTransfer textTransfer = TextTransfer.getInstance();
                cb.setContents(new Object[] { (textData != null ? textData : "") }, new Transfer[] { textTransfer });
            }
        }
    }
}
Also used : ITableCellRenderer(de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 34 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project egit by eclipse.

the class CopyHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Repository repo = getRepository(event);
    RevCommit commit = getSelectedCommit(event, repo);
    if (commit != null) {
        Clipboard clipboard = new Clipboard(null);
        try {
            TextTransfer textTransfer = TextTransfer.getInstance();
            Transfer[] transfers = new Transfer[] { textTransfer };
            Object[] data = new Object[] { ObjectId.toString(commit) };
            clipboard.setContents(data, transfers);
        } finally {
            clipboard.dispose();
        }
    }
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 35 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project tdq-studio-se by Talend.

the class CopyNodeNameAction method run.

/**
 * Copy the name of the selected node to the clipboard.
 *
 * @see org.eclipse.jface.action.IAction#run()
 */
public void run() {
    Clipboard clipBoard = new Clipboard(Display.getCurrent());
    TextTransfer textTransfer = TextTransfer.getInstance();
    StringBuffer text = new StringBuffer("");
    String sep = "";
    for (int i = 0; i < _selectedNodes.length; i++) {
        text.append(sep);
        text.append(_selectedNodes[i].getQualifiedName());
        sep = ", ";
    }
    clipBoard.setContents(new Object[] { text.toString() }, new Transfer[] { textTransfer });
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Aggregations

TextTransfer (org.eclipse.swt.dnd.TextTransfer)77 Clipboard (org.eclipse.swt.dnd.Clipboard)65 Point (org.eclipse.swt.graphics.Point)19 Transfer (org.eclipse.swt.dnd.Transfer)18 TableItem (org.eclipse.swt.widgets.TableItem)14 StyledText (org.eclipse.swt.custom.StyledText)10 Control (org.eclipse.swt.widgets.Control)8 Text (org.eclipse.swt.widgets.Text)6 IAction (org.eclipse.jface.action.IAction)5 HTMLTransfer (org.eclipse.swt.dnd.HTMLTransfer)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Button (org.eclipse.swt.widgets.Button)5 Composite (org.eclipse.swt.widgets.Composite)5 ArrayList (java.util.ArrayList)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Label (org.eclipse.swt.widgets.Label)4