Search in sources :

Example 71 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project pentaho-kettle by pentaho.

the class GUIResource method fromClipboard.

public String fromClipboard() {
    getNewClipboard();
    TextTransfer tran = TextTransfer.getInstance();
    return (String) clipboard.getContents(tran);
}
Also used : TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 72 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project pentaho-kettle by pentaho.

the class TableView method clipSelected.

private void clipSelected() {
    if (clipboard != null) {
        clipboard.dispose();
        clipboard = null;
    }
    clipboard = new Clipboard(getDisplay());
    TextTransfer tran = TextTransfer.getInstance();
    String clip = getSelectedText();
    if (clip == null) {
        return;
    }
    clipboard.setContents(new String[] { clip }, new Transfer[] { tran });
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 73 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project dbeaver by serge-rider.

the class DBeaverUI method copyTextToClipboard.

@Override
public void copyTextToClipboard(String text, boolean htmlFormat) {
    if (CommonUtils.isEmpty(text)) {
        return;
    }
    UIUtils.syncExec(() -> {
        TextTransfer textTransfer = TextTransfer.getInstance();
        Clipboard clipboard = new Clipboard(UIUtils.getDisplay());
        if (htmlFormat) {
            HTMLTransfer htmlTransfer = HTMLTransfer.getInstance();
            clipboard.setContents(new Object[] { text, text }, new Transfer[] { textTransfer, htmlTransfer });
        } else {
            clipboard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
        }
    });
}
Also used : HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 74 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project dbeaver by serge-rider.

the class ResultSetUtils method copyToClipboard.

public static void copyToClipboard(String string) {
    if (string != null && string.length() > 0) {
        Clipboard clipboard = new Clipboard(Display.getCurrent());
        try {
            TextTransfer textTransfer = TextTransfer.getInstance();
            clipboard.setContents(new Object[] { string }, new Transfer[] { textTransfer });
        } finally {
            clipboard.dispose();
        }
    }
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 75 with TextTransfer

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

the class GitRepositoriesViewRepoHandlingTest method testCopyPathToClipboard.

@Test
public void testCopyPathToClipboard() throws Exception {
    clearView();
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile);
    refreshAndWait();
    final SWTBotTree tree = getOrOpenView().bot().tree();
    tree.getAllItems()[0].select();
    waitInUI();
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            Clipboard clp = new Clipboard(Display.getCurrent());
            clp.clearContents();
            clp.setContents(new Object[] { "x" }, new TextTransfer[] { TextTransfer.getInstance() });
            String value = (String) clp.getContents(TextTransfer.getInstance());
            assertEquals("Clipboard content should be x", "x", value);
            ContextMenuHelper.clickContextMenuSync(tree, myUtil.getPluginLocalizedValue("CopyPathCommand"));
            value = (String) clp.getContents(TextTransfer.getInstance());
            assertTrue("Clipboard content (" + value + ")should be a repository path", FileKey.isGitRepository(new File(value), FS.DETECTED));
            clp.dispose();
        }
    });
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) Clipboard(org.eclipse.swt.dnd.Clipboard) File(java.io.File) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Test(org.junit.Test)

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