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);
}
}
use of org.eclipse.swt.dnd.Clipboard in project eclipse.platform.swt by eclipse.
the class ClipboardExample method open.
public void open(Display display) {
clipboard = new Clipboard(display);
shell = new Shell(display);
shell.setText("SWT Clipboard");
shell.setLayout(new FillLayout());
ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
Composite parent = new Composite(sc, SWT.NONE);
sc.setContent(parent);
parent.setLayout(new GridLayout(2, true));
Group copyGroup = new Group(parent, SWT.NONE);
copyGroup.setText("Copy From:");
GridData data = new GridData(GridData.FILL_BOTH);
copyGroup.setLayoutData(data);
copyGroup.setLayout(new GridLayout(3, false));
Group pasteGroup = new Group(parent, SWT.NONE);
pasteGroup.setText("Paste To:");
data = new GridData(GridData.FILL_BOTH);
pasteGroup.setLayoutData(data);
pasteGroup.setLayout(new GridLayout(3, false));
Group controlGroup = new Group(parent, SWT.NONE);
controlGroup.setText("Control API:");
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
controlGroup.setLayoutData(data);
controlGroup.setLayout(new GridLayout(5, false));
Group typesGroup = new Group(parent, SWT.NONE);
typesGroup.setText("Available Types");
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
typesGroup.setLayoutData(data);
typesGroup.setLayout(new GridLayout(2, false));
status = new Label(parent, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
status.setLayoutData(data);
createTextTransfer(copyGroup, pasteGroup);
createRTFTransfer(copyGroup, pasteGroup);
createHTMLTransfer(copyGroup, pasteGroup);
createFileTransfer(copyGroup, pasteGroup);
createImageTransfer(copyGroup, pasteGroup);
createMyTransfer(copyGroup, pasteGroup);
createControlTransfer(controlGroup);
createAvailableTypes(typesGroup);
sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle monitorArea = shell.getMonitor().getClientArea();
shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
clipboard.dispose();
}
use of org.eclipse.swt.dnd.Clipboard in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_custom_StyledText method test_cut.
@Test
public void test_cut() {
if (SwtTestUtil.isCocoa) {
// TODO Fix Cocoa failure.
if (SwtTestUtil.verbose) {
System.out.println("Excluded test_cut(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_custom_StyledText).");
}
return;
}
Clipboard clipboard = new Clipboard(text.getDisplay());
TextTransfer transfer = TextTransfer.getInstance();
String clipboardText;
String convertedText;
String before = (String) clipboard.getContents(transfer);
text.setSelectionRange(0, 0);
text.cut();
clipboardText = (String) clipboard.getContents(transfer);
assertTrue(":a:", before == null ? clipboardText == null : before.equals(clipboardText));
before = (String) clipboard.getContents(transfer);
text.setText("0123456789");
text.setSelectionRange(0, 0);
text.cut();
clipboardText = (String) clipboard.getContents(transfer);
assertTrue(":c:", before == null ? clipboardText == null : before.equals(clipboardText));
text.setSelectionRange(0, 1);
text.cut();
clipboardText = (String) clipboard.getContents(transfer);
assertTrue(":d:", clipboardText != null && clipboardText.equals("0"));
text.setSelectionRange(1, 2);
text.cut();
clipboardText = (String) clipboard.getContents(transfer);
assertTrue(":e:", clipboardText != null && clipboardText.equals("23"));
// test line delimiter conversion
text.setText("\rLine1\nLine2\r\nLine3\n\rLine4\n");
text.setSelectionRange(0, text.getCharCount());
text.cut();
clipboardText = (String) clipboard.getContents(transfer);
if (SwtTestUtil.isWindowsOS) {
convertedText = "\r\nLine1\r\nLine2\r\nLine3\r\n\r\nLine4\r\n";
} else {
convertedText = "\nLine1\nLine2\nLine3\n\nLine4\n";
}
assertTrue(":f:", clipboardText != null && clipboardText.equals(convertedText));
// test line delimiter conversion
text.setText("Line1\r\nLine2");
text.setSelectionRange(0, text.getCharCount());
text.cut();
clipboardText = (String) clipboard.getContents(transfer);
if (SwtTestUtil.isWindowsOS) {
convertedText = "Line1\r\nLine2";
} else {
convertedText = "Line1\nLine2";
}
assertTrue(":g:", clipboardText != null && clipboardText.equals(convertedText));
clipboard.dispose();
}
Aggregations