use of org.eclipse.swt.dnd.Clipboard 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.Clipboard 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.Clipboard 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.Clipboard 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);
}
}
}
use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.
the class CommonUITool method copyContentToClipboard.
/**
* Copy the data to clipboard
*
* @param data String
*/
public static void copyContentToClipboard(String data) {
if (data == null || data.trim().length() == 0) {
return;
}
TextTransfer textTransfer = TextTransfer.getInstance();
Clipboard clipboard = CommonUITool.getClipboard();
if (clipboard != null) {
clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
}
}
Aggregations