/* * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData */ @Override public void dragSetData(DragSourceEvent event) { if (EditorInputTransfer.getInstance().isSupportedType(event.dataType) && fEditorInputDatas.size() > 0) { event.data = fEditorInputDatas.toArray(new EditorInputData[fEditorInputDatas.size()]); } }
/* * @see org.eclipse.swt.dnd.DragSourceListener#dragStart */ @Override public void dragStart(DragSourceEvent event) { fEditorInputDatas = new ArrayList<EditorInputData>(); ISelection selection = fProvider.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext(); ) { Object element = iter.next(); IEditorInput editorInput = EditorUtility.getEditorInput(element); if (editorInput != null && editorInput.getPersistable() != null) { try { String editorId = EditorUtility.getEditorID(editorInput); // see org.eclipse.ui.internal.ide.EditorAreaDropAdapter.openNonExternalEditor(..): IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc = editorReg.findEditor(editorId); if (editorDesc != null && !editorDesc.isOpenExternal()) { fEditorInputDatas.add( EditorInputTransfer.createEditorInputData(editorId, editorInput)); } } catch (PartInitException e) { JavaPlugin.log(e); } } } } event.doit = fEditorInputDatas.size() > 0; }
@Override public Transfer[] getSupportedTransferTypes() { return new Transfer[] { TextTransfer.getInstance(), FileTransfer.getInstance(), ResourceTransfer.getInstance(), EditorInputTransfer.getInstance(), LocalSelectionTransfer.getTransfer() }; }
/* * @see TransferDragSourceListener#getTransfer */ public Transfer getTransfer() { return EditorInputTransfer.getInstance(); }