Search in sources :

Example 46 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.

the class QueryExecuter method copySelectedItems.

public void copySelectedItems() {
    CommonUITool.clearClipboard();
    StringBuilder content = new StringBuilder();
    List<Point> selectedList = selectableSupport.getSelectedLocations();
    int currentRow = -1;
    int len = selectedList.size();
    for (int i = 0; i < len; i++) {
        Point location = selectedList.get(i);
        if (i == 0) {
            currentRow = location.y;
        } else if (currentRow != location.y) {
            content.append(StringUtil.NEWLINE);
            currentRow = location.y;
        }
        TableItem item = tblResult.getItem(currentRow);
        if (!DataType.VALUE_NULL.equals(item.getData(location.x + ""))) {
            content.append(item.getText(location.x));
        } else {
            content.append("");
        }
        if (i + 1 < len) {
            content.append("\t");
        }
    }
    TextTransfer textTransfer = TextTransfer.getInstance();
    Clipboard clipboard = CommonUITool.getClipboard();
    if (clipboard != null) {
        IAction pasteAction = ActionManager.getInstance().getAction(PasteAction.ID);
        pasteAction.setEnabled(true);
        clipboard.setContents(new Object[] { content.toString() }, new Transfer[] { textTransfer });
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) Clipboard(org.eclipse.swt.dnd.Clipboard) Point(org.eclipse.swt.graphics.Point) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 47 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project cubrid-manager by CUBRID.

the class LogEditorPart method copyDataToClipboard.

/**
	 *
	 * Copy the selected data to clipboard
	 *
	 * @param type String
	 */
private void copyDataToClipboard(String type) {
    TextTransfer textTransfer = TextTransfer.getInstance();
    Clipboard clipboard = CommonUITool.getClipboard();
    StringBuilder content = new StringBuilder();
    TableItem[] items = table.getSelection();
    for (int i = 0; i < items.length; i++) {
        if (CubridNodeType.BROKER_SQL_LOG.equals(type)) {
            content.append(items[i].getText(1) + System.getProperty("line.separator"));
        }
        if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type)) {
            content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + items[i].getText(5) + blank + items[i].getText(6) + blank + System.getProperty("line.separator"));
        }
        if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type)) {
            content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + System.getProperty("line.separator"));
        }
        if (CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
            content.append(items[i].getText(1) + blank + items[i].getText(2) + blank + items[i].getText(3) + blank + items[i].getText(4) + blank + items[i].getText(5) + blank + items[i].getText(6) + blank + System.getProperty("line.separator"));
        }
    }
    String data = content.toString();
    if (data != null && !data.equals("")) {
        clipboard.setContents(new Object[] { data }, new Transfer[] { textTransfer });
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 48 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project tdi-studio-se by Talend.

the class CopyColumnNameAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.IAction#run()
     */
public void run() {
    try {
        Clipboard clipBoard = new Clipboard(Display.getCurrent());
        TextTransfer textTransfer = TextTransfer.getInstance();
        TableItem[] items = ptable.getSelection();
        if (items == null || items.length == 0) {
            return;
        }
        int columnIndex = pcursor.getColumn();
        TableColumn column = ptable.getColumn(columnIndex);
        clipBoard.setContents(new Object[] { column.getText() }, new Transfer[] { textTransfer });
    } catch (Exception e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(org.talend.sqlbuilder.Messages.getString("CopyColumnNameAction.logMessage"), e);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Clipboard(org.eclipse.swt.dnd.Clipboard) TableColumn(org.eclipse.swt.widgets.TableColumn) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 49 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project tdi-studio-se by Talend.

the class CopyCellAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.IAction#run()
     */
public void run() {
    try {
        Clipboard clipBoard = new Clipboard(Display.getCurrent());
        TextTransfer textTransfer = TextTransfer.getInstance();
        TableItem[] items = ptable.getSelection();
        if (items == null || items.length == 0) {
            return;
        }
        int columnIndex = pcursor.getColumn();
        clipBoard.setContents(new Object[] { items[0].getText(columnIndex) }, new Transfer[] { textTransfer });
    } catch (Exception e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(org.talend.sqlbuilder.Messages.getString("CopyCellAction.logMessage"), e);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) 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