use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.
the class QueryExecuter method copySelectedItems.
public void copySelectedItems() {
CommonUITool.clearClipboard();
StringBuilder content = new StringBuilder();
List<Point> selectedList = selectableSupport.getSelectedLocations();
int currentRow = -1;
int len = selectedList.size();
for (int i = 0; i < len; i++) {
Point location = selectedList.get(i);
if (i == 0) {
currentRow = location.y;
} else if (currentRow != location.y) {
content.append(StringUtil.NEWLINE);
currentRow = location.y;
}
TableItem item = tblResult.getItem(currentRow);
if (!DataType.VALUE_NULL.equals(item.getData(location.x + ""))) {
content.append(item.getText(location.x));
} else {
content.append("");
}
if (i + 1 < len) {
content.append("\t");
}
}
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
if (clipboard != null) {
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
pasteAction.setEnabled(true);
clipboard.setContents(new Object[] { content.toString() }, new Transfer[] { textTransfer });
}
}
use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.
the class LogEditorPart method copyDataToClipboard.
/**
*
* Copy the selected data to clipboard
*
* @param type String
*/
private void copyDataToClipboard(String type) {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
StringBuilder content = new StringBuilder();
TableItem[] items = table.getSelection();
for (int i = 0; i < items.length; i++) {
if (CubridNodeType.BROKER_SQL_LOG.equals(type)) {
content.append(items[i].getText(1) + System.getProperty("line.separator"));
}
if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type)) {
content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + items[i].getText(5) + blank + items[i].getText(6) + blank + System.getProperty("line.separator"));
}
if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type)) {
content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + System.getProperty("line.separator"));
}
if (CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + items[i].getText(5) + blank + items[i].getText(6) + blank + System.getProperty("line.separator"));
}
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
use of org.eclipse.swt.dnd.Clipboard in project tdi-studio-se by Talend.
the class CopyColumnNameAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
TableItem[] items = ptable.getSelection();
if (items == null || items.length == 0) {
return;
}
int columnIndex = pcursor.getColumn();
TableColumn column = ptable.getColumn(columnIndex);
clipBoard.setContents(new Object[] { column.getText() }, new Transfer[] { textTransfer });
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(org.talend.sqlbuilder.Messages.getString("CopyColumnNameAction.logMessage"), e);
}
}
use of org.eclipse.swt.dnd.Clipboard in project tdi-studio-se by Talend.
the class CopyCellAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
try {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
TableItem[] items = ptable.getSelection();
if (items == null || items.length == 0) {
return;
}
int columnIndex = pcursor.getColumn();
clipBoard.setContents(new Object[] { items[0].getText(columnIndex) }, new Transfer[] { textTransfer });
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(org.talend.sqlbuilder.Messages.getString("CopyCellAction.logMessage"), e);
}
}
Aggregations