use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class ParamDumpResultDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.numColumns = 5;
composite.setLayout(layout);
//dynamicHelp end
createdbNameGroup(composite);
table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
table.setHeaderVisible(true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 7;
gridData.verticalSpan = 10;
gridData.heightHint = 300;
table.setLayoutData(gridData);
table.setLinesVisible(true);
CommonUITool.hackForYosemite(table);
/*
* // fill in context menu
*/
Menu menu = new Menu(parent.getShell(), SWT.POP_UP);
table.setMenu(menu);
MenuItem copy = new MenuItem(menu, SWT.PUSH);
copy.setText(Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.contextCopy, "Ctrl+C"));
copy.setAccelerator(SWT.CTRL + 'C');
copy.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
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(0) + blank + items[i].getText(1) + blank + items[i].getText(2) + blank + System.getProperty("line.separator"));
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
});
table.addKeyListener(new org.eclipse.swt.events.KeyAdapter() {
public void keyPressed(org.eclipse.swt.events.KeyEvent event) {
if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
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(0) + blank + items[i].getText(1) + blank + items[i].getText(2) + blank + System.getProperty("line.separator"));
}
String data = content.toString();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
}
});
setTitle(Messages.titleParamDumpDialog);
setMessage(Messages.msgParamDumpDialog);
initial();
return parentComp;
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class ColumnViewerSorter method copyNamesToClipboard.
public void copyNamesToClipboard(List<String> nameList) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final Clipboard cb = new Clipboard(shell.getDisplay());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < nameList.size(); i++) {
if (i != 0) {
sb.append(StringUtil.NEWLINE);
}
sb.append(nameList.get(i));
}
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { sb.toString() };
cb.setContents(data, transfers);
cb.dispose();
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class TableDashboardComposite method copyTablesDetailToClipboard.
public void copyTablesDetailToClipboard() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final Clipboard cb = new Clipboard(shell.getDisplay());
StringBuilder sb = new StringBuilder();
List<Integer> selectIndex = new ArrayList<Integer>();
SchemaInfo schema = (SchemaInfo) columnTableView.getInput();
List<DBAttribute> list = schema.getAttributes();
for (int i = 0; i < columnTableView.getTable().getSelectionIndices().length; i++) {
selectIndex.add(columnTableView.getTable().getSelectionIndices()[i]);
}
for (int i = 0; i < selectIndex.size(); i++) {
if (i != 0) {
sb.append(StringUtil.NEWLINE);
}
DBAttribute attr = list.get(i);
sb.append(attr.getName());
}
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { sb.toString() };
cb.setContents(data, transfers);
cb.dispose();
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class CopyAllAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
Control control = getFocusProvider();
if (control instanceof StyledText) {
StyledText stext = (StyledText) control;
String data = stext.getText();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
FocusAction.changeActionStatus(pasteAction, stext);
}
} else {
/*Copy from the active editor*/
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor != null && editor instanceof ICopiableFromTable) {
ICopiableFromTable copyAbleEditor = (ICopiableFromTable) editor;
copyAbleEditor.copyAllItems();
}
}
}
}
use of org.eclipse.swt.dnd.TextTransfer in project cubrid-manager by CUBRID.
the class CutAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
Control control = getFocusProvider();
if (control instanceof StyledText) {
StyledText stext = (StyledText) control;
String data = stext.getSelectionText();
if (data != null && !data.equals("")) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
Point range = stext.getSelectionRange();
stext.replaceTextRange(range.x, range.y, "");
stext.setSelection(range.x);
IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
FocusAction.changeActionStatus(pasteAction, stext);
}
}
}
Aggregations