Search in sources :

Example 21 with Clipboard

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

Example 22 with Clipboard

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();
}
Also used : ArrayList(java.util.ArrayList) Shell(org.eclipse.swt.widgets.Shell) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 23 with Clipboard

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();
            }
        }
    }
}
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)

Example 24 with Clipboard

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);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) Clipboard(org.eclipse.swt.dnd.Clipboard) Point(org.eclipse.swt.graphics.Point) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 25 with Clipboard

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

Aggregations

Clipboard (org.eclipse.swt.dnd.Clipboard)49 TextTransfer (org.eclipse.swt.dnd.TextTransfer)38 Transfer (org.eclipse.swt.dnd.Transfer)13 Point (org.eclipse.swt.graphics.Point)8 TableItem (org.eclipse.swt.widgets.TableItem)8 StyledText (org.eclipse.swt.custom.StyledText)7 Control (org.eclipse.swt.widgets.Control)6 ArrayList (java.util.ArrayList)4 IAction (org.eclipse.jface.action.IAction)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 Button (org.eclipse.swt.widgets.Button)3 Label (org.eclipse.swt.widgets.Label)3 Shell (org.eclipse.swt.widgets.Shell)3 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)2 ICopiableFromTable (com.cubrid.common.ui.query.editor.ICopiableFromTable)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2