Search in sources :

Example 66 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project tdq-studio-se by Talend.

the class CopyStatementAction method run.

public void run() {
    try {
        TableItem[] ti = _table.getSelection();
        if (ti == null || ti.length == 0) {
            return;
        }
        String queryDelimiter = SQLExplorerPlugin.getDefault().getPluginPreferences().getString(IConstants.SQL_QRY_DELIMITER);
        StringBuffer copiedText = new StringBuffer();
        for (int i = 0; i < ti.length; i++) {
            SQLHistoryElement el = (SQLHistoryElement) ti[i].getData();
            copiedText.append(el.getRawSQLString());
            if (ti.length > 0) {
                copiedText.append(queryDelimiter);
                copiedText.append("\n");
            }
        }
        Clipboard cb = new Clipboard(Display.getCurrent());
        TextTransfer textTransfer = TextTransfer.getInstance();
        cb.setContents(new Object[] { copiedText.toString() }, new Transfer[] { textTransfer });
    } catch (Throwable e) {
        SQLExplorerPlugin.error("Error copying to clipboard", e);
    }
}
Also used : SQLHistoryElement(net.sourceforge.sqlexplorer.history.SQLHistoryElement) TableItem(org.eclipse.swt.widgets.TableItem) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 67 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project tmdm-studio-se by Talend.

the class CopyUrlAction method multiCopy.

private void multiCopy() {
    StringBuilder result = new StringBuilder();
    List<Object> selectedObject = getSelectedObject();
    for (Object obj : selectedObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        // picture file info
        Item item = viewObject.getProperty().getItem();
        WSResourceE wsItem = null;
        if (!(item instanceof WSResourceItem)) {
            continue;
        }
        wsItem = ((WSResourceItem) item).getResource();
        String catalog = wsItem.getImageCatalog();
        if (catalog == null) {
            continue;
        }
        String fileName = viewObject.getLabel() + '.' + wsItem.getFileExtension();
        // MDMServerDef thing
        MDMServerDef serverDef = RepositoryResourceUtil.getLastServerDef(viewObject);
        if (serverDef == null) {
            continue;
        }
        // all picture url string
        String contextPath = Util.getContextPath(serverDef.getPath());
        String uripre = serverDef.getProtocol() + serverDef.getHost() + ':' + serverDef.getPort() + contextPath;
        result.append(uripre);
        // $NON-NLS-1$
        result.append("/imageserver/upload/" + catalog + '/' + fileName);
        result.append('\n');
    }
    // copy url to clipboard
    if (result.length() != 0) {
        Clipboard cb = new Clipboard(Display.getCurrent());
        String textData = result.toString();
        TextTransfer transfer = TextTransfer.getInstance();
        cb.setContents(new Object[] { textData }, new Transfer[] { transfer });
        cb.dispose();
    }
}
Also used : Item(org.talend.core.model.properties.Item) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) Clipboard(org.eclipse.swt.dnd.Clipboard) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 68 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project nebula.widgets.nattable by eclipse.

the class CopyDataToClipboardSerializer method serialize.

@Override
public void serialize() {
    final String cellDelimeter = this.command.getCellDelimeter();
    final String rowDelimeter = this.command.getRowDelimeter();
    final TextTransfer textTransfer = TextTransfer.getInstance();
    final StringBuilder textData = new StringBuilder();
    int currentRow = 0;
    for (ILayerCell[] cells : this.copiedCells) {
        int currentCell = 0;
        for (ILayerCell cell : cells) {
            final String delimeter = ++currentCell < cells.length ? cellDelimeter : // $NON-NLS-1$
            "";
            if (cell != null) {
                textData.append(getTextForCell(cell) + delimeter);
            } else {
                textData.append(delimeter);
            }
        }
        if (++currentRow < this.copiedCells.length) {
            textData.append(rowDelimeter);
        }
    }
    if (textData.length() > 0) {
        final Clipboard clipboard = new Clipboard(Display.getDefault());
        try {
            clipboard.setContents(new Object[] { textData.toString() }, new Transfer[] { textTransfer });
        } finally {
            clipboard.dispose();
        }
    }
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 69 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project dbeaver by dbeaver.

the class DBeaverUI method copyTextToClipboard.

@Override
public void copyTextToClipboard(String text, boolean htmlFormat) {
    if (CommonUtils.isEmpty(text)) {
        return;
    }
    UIUtils.syncExec(() -> {
        TextTransfer textTransfer = TextTransfer.getInstance();
        Clipboard clipboard = new Clipboard(UIUtils.getDisplay());
        if (htmlFormat) {
            HTMLTransfer htmlTransfer = HTMLTransfer.getInstance();
            clipboard.setContents(new Object[] { text, text }, new Transfer[] { textTransfer, htmlTransfer });
        } else {
            clipboard.setContents(new Object[] { text }, new Transfer[] { textTransfer });
        }
    });
}
Also used : HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 70 with TextTransfer

use of org.eclipse.swt.dnd.TextTransfer in project pentaho-kettle by pentaho.

the class GUIResource method toClipboard.

public void toClipboard(String cliptext) {
    if (cliptext == null) {
        return;
    }
    getNewClipboard();
    TextTransfer tran = TextTransfer.getInstance();
    clipboard.setContents(new String[] { cliptext }, new Transfer[] { tran });
}
Also used : 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