public void preWindowOpen() { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); // show the shortcut bar and progress indicator, which are hidden by // default configurer.setShowPerspectiveBar(true); configurer.setShowFastViewBars(true); configurer.setShowProgressIndicator(true); // add the drag and drop support for the editor area configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); configurer.addEditorAreaTransfer(FileTransfer.getInstance()); configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( configurer.getWindow())); hookTitleUpdateListeners(configurer); }
@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; }
public Transfer getTransfer() { return EditorInputTransfer.getInstance(); }
@Override public void dragSetData(DragSourceEvent event) { if (EditorInputTransfer.getInstance().isSupportedType(event.dataType) && fEditorInputDatas.size() > 0) { event.data= fEditorInputDatas.toArray(new EditorInputData[fEditorInputDatas.size()]); } }