Search in sources :

Example 1 with TransferProxyForDelayLoading

use of org.eclipse.wst.sse.ui.internal.TransferBuilder.TransferProxyForDelayLoading in project webtools.sourceediting by eclipse.

the class ExtendedEditorDropTargetAdapter method doDrop.

protected boolean doDrop(Transfer transfer, DropTargetEvent event) {
    TransferBuilder tb = new TransferBuilder(useProxy);
    IDropAction[] as = null;
    if (editorIds != null && editorIds.length > 0)
        as = tb.getDropActions(editorIds, transfer);
    else
        as = tb.getDropActions(getTargetEditor().getClass().getName(), transfer);
    for (int i = 0; i < as.length; ++i) {
        IDropAction da = as[i];
        Transfer actualTransfer;
        if (transfer instanceof TransferProxyForDelayLoading) {
            actualTransfer = ((TransferProxyForDelayLoading) transfer).getTransferClass();
        } else {
            actualTransfer = transfer;
        }
        if (actualTransfer instanceof FileTransfer) {
            if (event.data == null) {
                // $NON-NLS-1$
                Logger.log(Logger.ERROR, "No data in DropTargetEvent from " + event.widget);
                return false;
            }
            String[] strs = (String[]) event.data;
            boolean[] bs = new boolean[strs.length];
            int c = 0;
            for (int j = 0; j < strs.length; ++j) {
                bs[j] = false;
                if (da.isSupportedData(strs[j])) {
                    event.data = new String[] { strs[j] };
                    if (!da.run(event, targetEditor)) {
                        bs[j] = true;
                        c++;
                    }
                } else {
                    bs[j] = true;
                    c++;
                }
            }
            if (c == 0) {
                return true;
            }
            int k = 0;
            String[] rests = new String[c];
            for (int j = 0; j < strs.length; ++j) {
                if (bs[j])
                    rests[k++] = strs[j];
            }
            event.data = rests;
        } else if (da.isSupportedData(event.data)) {
            if (da.run(event, targetEditor)) {
                return true;
            }
        }
    }
    return false;
}
Also used : FileTransfer(org.eclipse.swt.dnd.FileTransfer) Transfer(org.eclipse.swt.dnd.Transfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) TransferProxyForDelayLoading(org.eclipse.wst.sse.ui.internal.TransferBuilder.TransferProxyForDelayLoading) Point(org.eclipse.swt.graphics.Point)

Aggregations

FileTransfer (org.eclipse.swt.dnd.FileTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 Point (org.eclipse.swt.graphics.Point)1 TransferProxyForDelayLoading (org.eclipse.wst.sse.ui.internal.TransferBuilder.TransferProxyForDelayLoading)1