Search in sources :

Example 6 with TextTransfer

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;
}
Also used : Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) MenuItem(org.eclipse.swt.widgets.MenuItem) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Event(org.eclipse.swt.widgets.Event) Menu(org.eclipse.swt.widgets.Menu) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 7 with TextTransfer

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

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

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

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

Aggregations

TextTransfer (org.eclipse.swt.dnd.TextTransfer)77 Clipboard (org.eclipse.swt.dnd.Clipboard)65 Point (org.eclipse.swt.graphics.Point)19 Transfer (org.eclipse.swt.dnd.Transfer)18 TableItem (org.eclipse.swt.widgets.TableItem)14 StyledText (org.eclipse.swt.custom.StyledText)10 Control (org.eclipse.swt.widgets.Control)8 Text (org.eclipse.swt.widgets.Text)6 IAction (org.eclipse.jface.action.IAction)5 HTMLTransfer (org.eclipse.swt.dnd.HTMLTransfer)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Button (org.eclipse.swt.widgets.Button)5 Composite (org.eclipse.swt.widgets.Composite)5 ArrayList (java.util.ArrayList)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Label (org.eclipse.swt.widgets.Label)4