private IEditorPart showWithReuse(Object element, IWorkbenchPage wbPage) throws PartInitException { IEditorInput input= EditorUtility.getEditorInput(element); if (input == null) return null; String editorID= EditorUtility.getEditorID(input); return showInEditor(wbPage, input, editorID); }
private IEditorPart showWithReuse(Object element, IWorkbenchPage wbPage) throws PartInitException { IEditorInput input= EditorUtility.getEditorInput(element); if (input == null) return null; String editorID= EditorUtility.getEditorID(input); return showInEditor(wbPage, input, editorID); }
@Override public void dragStart(DragSourceEvent event) { fEditorInputDatas= new ArrayList<>(); 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 void dragStart(DragSourceEvent event) { fEditorInputDatas= new ArrayList<>(); 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; }
/** * Opens the editor currently associated with the given element (IJavaElement, IFile, IStorage...) * * @param inputElement the input element * @param activate <code>true</code> if the editor should be activated * @return an open editor or <code>null</code> if an external editor was opened * @throws PartInitException if the editor could not be opened or the input element is not valid * Status code {@link IJavaStatusConstants#EDITOR_NO_EDITOR_INPUT} if opening the editor failed as * no editor input could be created for the given element. */ public static IEditorPart openInEditor(Object inputElement, boolean activate) throws PartInitException { if (inputElement instanceof IFile) { IFile file= (IFile) inputElement; if (!isClassFile(file)) return openInEditor(file, activate); inputElement= JavaCore.createClassFileFrom(file); } IEditorPart editor= findEditor(inputElement, activate); if (editor != null) return editor; IEditorInput input= getEditorInput(inputElement); if (input == null) throwPartInitException(JavaEditorMessages.EditorUtility_no_editorInput, IJavaStatusConstants.EDITOR_NO_EDITOR_INPUT); return openInEditor(input, getEditorID(input), activate); }
/** * Opens the editor currently associated with the given element (IJavaElement, IFile, IStorage...) * * @param inputElement the input element * @param activate <code>true</code> if the editor should be activated * @return an open editor or <code>null</code> if an external editor was opened * @throws PartInitException if the editor could not be opened or the input element is not valid * Status code {@link IJavaStatusConstants#EDITOR_NO_EDITOR_INPUT} if opening the editor failed as * no editor input could be created for the given element. */ public static IEditorPart openInEditor(Object inputElement, boolean activate) throws PartInitException { if (inputElement instanceof IFile) { IFile file= (IFile) inputElement; if (!isClassFile(file)) return openInEditor(file, activate); inputElement= JavaCore.createClassFileFrom(file); } IEditorPart editor= findEditor(inputElement, activate); if (editor != null) return editor; IEditorInput input= getEditorInput(inputElement); if (input == null) throwPartInitException(JavaEditorMessages.EditorUtility_no_editorInput, IJavaStatusConstants.EDITOR_NO_EDITOR_INPUT); return openInEditor(input, getEditorID(input), activate); }
throwPartInitException(JavaEditorMessages.EditorUtility_no_editorInput); return openInEditor(input, getEditorID(input), activate);