use of org.eclipse.swt.dnd.TextTransfer in project bndtools by bndtools.
the class ResolutionFailurePanel method copyUnresolvedToClipboard.
// private void switchFailureViewMode() {
// Object input = unresolvedViewer.getInput();
// unresolvedViewer.setInput(null);
// setFailureViewMode();
// unresolvedViewer.setInput(input);
// unresolvedViewer.expandToLevel(2);
// }
private void copyUnresolvedToClipboard() {
StringBuilder builder = new StringBuilder();
Object input = unresolvedViewer.getInput();
if (input == null)
return;
ITreeContentProvider contentProvider = (ITreeContentProvider) unresolvedViewer.getContentProvider();
Object[] roots = contentProvider.getElements(input);
ViewerSorter sorter = unresolvedViewer.getSorter();
if (sorter != null)
Arrays.sort(roots, new SorterComparatorAdapter(unresolvedViewer, sorter));
for (Object root : roots) {
appendLabels(root, contentProvider, builder, 0);
}
/*
* TODO if (result != null) { StringBuilder buffer = new StringBuilder(); List<Reason> unresolved =
* result.getUnresolved(); if (unresolved != null) for (Iterator<Reason> iter = unresolved.iterator();
* iter.hasNext(); ) { Reason reason = iter.next();
* buffer.append(unresolvedLabelProvider.getLabel(reason.getRequirement ()).getString()); buffer.append('\t');
* buffer.append(unresolvedLabelProvider .getLabel(reason.getResource())); if (iter.hasNext())
* buffer.append('\n'); } }
*/
Clipboard clipboard = new Clipboard(composite.getDisplay());
TextTransfer transfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { builder.toString() }, new Transfer[] { transfer });
clipboard.dispose();
}
use of org.eclipse.swt.dnd.TextTransfer in project dbeaver by dbeaver.
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 translationstudio8 by heartsome.
the class DefaultCCPStrategy method paste.
/**
* Paste pastes textual context starting at the focussed cell (does not use the selection by now). Uses TAB and
* semicolon as delimiters (Excel uses TAB, semicolon for pasting csv).
*
* @param table the jaret table
*/
public void paste(JaretTable table) {
Clipboard cb = getClipboard();
TextTransfer textTransfer = TextTransfer.getInstance();
Object content = cb.getContents(textTransfer);
if (content != null) {
if (content instanceof String) {
String string = (String) content;
List<String> lines = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(string, "\n");
while (tokenizer.hasMoreTokens()) {
lines.add(tokenizer.nextToken());
}
Point focus = table.getFocussedCellIdx();
if (focus == null) {
table.setFocus();
focus = table.getFocussedCellIdx();
}
int lineOff = 0;
for (String line : lines) {
tokenizer = new StringTokenizer(line, PASTE_DELIMITERS, true);
int colOff = 0;
String last = null;
while (tokenizer.hasMoreTokens()) {
String value = tokenizer.nextToken();
boolean ignore = false;
if (PASTE_DELIMITERS.indexOf(value) != -1) {
// delimiter
if (last != null && last.equals(value)) {
value = "";
} else {
ignore = true;
}
}
if (!ignore) {
try {
table.setValue(focus.x + colOff, focus.y + lineOff, value);
} catch (Exception e) {
// silently ignore -- this can happen
}
colOff++;
}
last = value;
}
lineOff++;
}
}
}
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class TableSchemaCompareInfoPart method copyTableAlterDDL.
/**
* copyTableLeftAlterDDL
*/
private void copyTableAlterDDL(CubridDatabase leftDB, CubridDatabase rightDB, boolean leftToRight) {
// FIXME logic code move to core module
StringBuffer clipboardDataString = new StringBuffer();
TableItem[] tableItems = tablesSchemaCompareTable.getTable().getSelection();
String title = "";
String msg = "";
for (int i = 0; i < tableItems.length; i++) {
if (i > 0) {
clipboardDataString.append(StringUtil.NEWLINE);
clipboardDataString.append(StringUtil.NEWLINE);
}
TableSchemaCompareModel compareModel = (TableSchemaCompareModel) tableItems[i].getData();
TableSchema leftTableSchema = (TableSchema) compareModel.getLeft();
TableSchema rightTableSchema = (TableSchema) compareModel.getRight();
String tableCompare = leftTableSchema.getName();
if (StringUtil.isEmpty(leftTableSchema.getName())) {
tableCompare = rightTableSchema.getName();
}
String alterDDL = null;
if (compareModel.getCompareStatus() != TableSchemaCompareModel.SCHEMA_EQUAL && compareModel.getCompareStatus() != TableSchemaCompareModel.RECORDS_DIFF) {
Map<String, SchemaInfo> sourceSchemas = compareModel.getSourceSchemas();
Map<String, SchemaInfo> targetSchemas = compareModel.getTargetSchemas();
SchemaInfo sourceTableSchemaInfo = null;
SchemaInfo targetTableSchemaInfo = null;
if (leftToRight) {
sourceTableSchemaInfo = sourceSchemas.get(tableCompare);
targetTableSchemaInfo = targetSchemas.get(tableCompare);
} else {
targetTableSchemaInfo = sourceSchemas.get(tableCompare);
sourceTableSchemaInfo = targetSchemas.get(tableCompare);
}
alterDDL = tableComp.getTableAlterScript(leftDB, rightDB, tableCompare, sourceTableSchemaInfo, targetTableSchemaInfo);
if (StringUtil.isNotEmpty(alterDDL)) {
clipboardDataString.append(alterDDL.trim());
}
}
}
Clipboard clipboard = CommonUITool.getClipboard();
if (clipboardDataString.length() != 0) {
if ("--NotSupportAlterAutoIncrement".equals(clipboardDataString.toString())) {
title = Messages.compareStatusTip;
msg = Messages.alterAutoIncrementNotSupport;
} else {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { clipboardDataString.toString() };
clipboard.setContents(data, transfers);
title = Messages.alterScript;
msg = Messages.tableSchemaAlterCopyMessage;
}
} else {
clipboard.clearContents();
title = Messages.emptyAlterScript;
msg = Messages.schemaIdenticalMessage;
}
CommonUITool.openInformationBox(title, msg);
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class ImportResultDialog method copyDataToClipboard.
/**
*
* Copy the selected data to clipboard
*
*/
private void copyDataToClipboard() {
// FIXME move this logic to core module
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
StringBuilder content = new StringBuilder();
TableItem[] items = table.getSelection();
for (int i = 0; i < items.length; i++) {
content.append(items[i].getText(1) + System.getProperty("line.separator"));
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
Aggregations