use of org.eclipse.swt.dnd.Clipboard in project GT by Tencent.
the class CopyAllFromTreeViewAction method run.
@Override
public void run() {
StringBuffer sb = getContents();
clipboard = new Clipboard(Display.getCurrent());
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
clipboard.setContents(new String[] { sb.toString() }, transfers);
}
use of org.eclipse.swt.dnd.Clipboard in project GT by Tencent.
the class CopySelectedItemsFromTreeViewAction method run.
@Override
public void run() {
StringBuffer sb = getContents();
clipboard = new Clipboard(Display.getCurrent());
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
clipboard.setContents(new String[] { sb.toString() }, transfers);
}
use of org.eclipse.swt.dnd.Clipboard in project dbeaver by serge-rider.
the class ResultSetUtils method getAttributeValueFromClipboard.
@Nullable
public static Object getAttributeValueFromClipboard(DBDAttributeBinding attribute) throws DBCException {
DBPDataSource dataSource = attribute.getDataSource();
Clipboard clipboard = new Clipboard(Display.getCurrent());
try (DBCSession session = DBUtils.openUtilSession(VoidProgressMonitor.INSTANCE, dataSource, "Copy from clipboard")) {
String strValue = (String) clipboard.getContents(TextTransfer.getInstance());
return attribute.getValueHandler().getValueFromObject(session, attribute.getAttribute(), strValue, true);
} finally {
clipboard.dispose();
}
}
use of org.eclipse.swt.dnd.Clipboard in project dbeaver by serge-rider.
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.Clipboard in project cubrid-manager by CUBRID.
the class CopyAction 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 });
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.copySelectedItems();
}
}
}
}
Aggregations