use of org.eclipse.swt.dnd.TextTransfer in project tdq-studio-se by Talend.
the class CopyStatementAction method run.
public void run() {
try {
TableItem[] ti = _table.getSelection();
if (ti == null || ti.length == 0) {
return;
}
String queryDelimiter = SQLExplorerPlugin.getDefault().getPluginPreferences().getString(IConstants.SQL_QRY_DELIMITER);
StringBuffer copiedText = new StringBuffer();
for (int i = 0; i < ti.length; i++) {
SQLHistoryElement el = (SQLHistoryElement) ti[i].getData();
copiedText.append(el.getRawSQLString());
if (ti.length > 0) {
copiedText.append(queryDelimiter);
copiedText.append("\n");
}
}
Clipboard cb = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[] { copiedText.toString() }, new Transfer[] { textTransfer });
} catch (Throwable e) {
SQLExplorerPlugin.error("Error copying to clipboard", e);
}
}
use of org.eclipse.swt.dnd.TextTransfer in project tmdm-studio-se by Talend.
the class CopyUrlAction method multiCopy.
private void multiCopy() {
StringBuilder result = new StringBuilder();
List<Object> selectedObject = getSelectedObject();
for (Object obj : selectedObject) {
IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
// picture file info
Item item = viewObject.getProperty().getItem();
WSResourceE wsItem = null;
if (!(item instanceof WSResourceItem)) {
continue;
}
wsItem = ((WSResourceItem) item).getResource();
String catalog = wsItem.getImageCatalog();
if (catalog == null) {
continue;
}
String fileName = viewObject.getLabel() + '.' + wsItem.getFileExtension();
// MDMServerDef thing
MDMServerDef serverDef = RepositoryResourceUtil.getLastServerDef(viewObject);
if (serverDef == null) {
continue;
}
// all picture url string
String contextPath = Util.getContextPath(serverDef.getPath());
String uripre = serverDef.getProtocol() + serverDef.getHost() + ':' + serverDef.getPort() + contextPath;
result.append(uripre);
// $NON-NLS-1$
result.append("/imageserver/upload/" + catalog + '/' + fileName);
result.append('\n');
}
// copy url to clipboard
if (result.length() != 0) {
Clipboard cb = new Clipboard(Display.getCurrent());
String textData = result.toString();
TextTransfer transfer = TextTransfer.getInstance();
cb.setContents(new Object[] { textData }, new Transfer[] { transfer });
cb.dispose();
}
}
use of org.eclipse.swt.dnd.TextTransfer in project nebula.widgets.nattable by eclipse.
the class CopyDataToClipboardSerializer method serialize.
@Override
public void serialize() {
final String cellDelimeter = this.command.getCellDelimeter();
final String rowDelimeter = this.command.getRowDelimeter();
final TextTransfer textTransfer = TextTransfer.getInstance();
final StringBuilder textData = new StringBuilder();
int currentRow = 0;
for (ILayerCell[] cells : this.copiedCells) {
int currentCell = 0;
for (ILayerCell cell : cells) {
final String delimeter = ++currentCell < cells.length ? cellDelimeter : // $NON-NLS-1$
"";
if (cell != null) {
textData.append(getTextForCell(cell) + delimeter);
} else {
textData.append(delimeter);
}
}
if (++currentRow < this.copiedCells.length) {
textData.append(rowDelimeter);
}
}
if (textData.length() > 0) {
final Clipboard clipboard = new Clipboard(Display.getDefault());
try {
clipboard.setContents(new Object[] { textData.toString() }, new Transfer[] { textTransfer });
} finally {
clipboard.dispose();
}
}
}
use of org.eclipse.swt.dnd.TextTransfer in project dbeaver by dbeaver.
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 pentaho-kettle by pentaho.
the class GUIResource method toClipboard.
public void toClipboard(String cliptext) {
if (cliptext == null) {
return;
}
getNewClipboard();
TextTransfer tran = TextTransfer.getInstance();
clipboard.setContents(new String[] { cliptext }, new Transfer[] { tran });
}
Aggregations