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);
}
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 });
}
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 });
}
});
}
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();
}
}
}
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();
}
});
}
Aggregations