Search in sources :

Example 51 with Clipboard

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);
}
Also used : TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 52 with Clipboard

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);
}
Also used : TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 53 with Clipboard

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();
    }
}
Also used : DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) Clipboard(org.eclipse.swt.dnd.Clipboard) Nullable(org.jkiss.code.Nullable)

Example 54 with Clipboard

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();
        }
    }
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 55 with Clipboard

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();
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ICopiableFromTable(com.cubrid.common.ui.query.editor.ICopiableFromTable) Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) Clipboard(org.eclipse.swt.dnd.Clipboard) IEditorPart(org.eclipse.ui.IEditorPart) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Aggregations

Clipboard (org.eclipse.swt.dnd.Clipboard)73 TextTransfer (org.eclipse.swt.dnd.TextTransfer)50 Transfer (org.eclipse.swt.dnd.Transfer)19 Point (org.eclipse.swt.graphics.Point)12 StyledText (org.eclipse.swt.custom.StyledText)8 Composite (org.eclipse.swt.widgets.Composite)7 Display (org.eclipse.swt.widgets.Display)7 IAction (org.eclipse.jface.action.IAction)6 ISelection (org.eclipse.jface.viewers.ISelection)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Control (org.eclipse.swt.widgets.Control)6 TableItem (org.eclipse.swt.widgets.TableItem)6 ArrayList (java.util.ArrayList)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 GridData (org.eclipse.swt.layout.GridData)5 Event (org.eclipse.swt.widgets.Event)4 Shell (org.eclipse.swt.widgets.Shell)4 Rectangle (org.eclipse.swt.graphics.Rectangle)3