private void initializeSuggestion() { if (fileName == null) { return; } IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor suggestion = editorRegistry.getDefaultEditor(fileName); if (suggestion != null && suggestion.isInternal()) { selectedEditor = suggestion; } else { selectedEditor = findBestExternalEditor(); } boolean enableInternalList = selectedEditor == null || selectedEditor.isInternal(); internalButton.setSelection(enableInternalList); externalButton.setSelection(!enableInternalList); }
private static String getEditorId(IStorage storage) { String id; IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor descriptor = registry.getDefaultEditor(storage.getName()); if (descriptor == null || !descriptor.isInternal()) { id = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } else { try { if (Utils.isTextEditor(descriptor)) { id = descriptor.getId(); } else { id = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } } catch (CoreException e) { id = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } } return id; }
private static String getEditorId(IStorage storage) { String id; IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor descriptor = registry.getDefaultEditor(storage.getName()); if (descriptor == null || !descriptor.isInternal()) { id = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } else { try { if (isTextEditor(descriptor)) { id = descriptor.getId(); } else { id = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } } catch (CoreException e) { id = EditorsUI.DEFAULT_TEXT_EDITOR_ID; } } return id; }
private ITextEditor openNewTextEditor(IFile file, IWorkbenchPage activePage) throws PartInitException { IEditorDescriptor desc= IDE.getDefaultEditor(file); if (desc != null) { String editorID= desc.getId(); IEditorPart editor; if (desc.isInternal()) { editor= activePage.openEditor(new FileEditorInput(file), editorID); if (editor instanceof ITextEditor) { if (editor instanceof IReusableEditor) fEditor= (IReusableEditor) editor; return (ITextEditor)editor; } activePage.closeEditor(editor, false); } } IEditorPart editor= activePage.openEditor(new FileEditorInput(file), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ return (ITextEditor)editor; }
public IEditorPart openAndSelect(IWorkbenchPage wbPage, IFile file, int offset, int length, boolean activate) throws PartInitException { String editorId= null; IEditorDescriptor desc = IDE.getEditorDescriptor(file, true, true); if (desc == null || !desc.isInternal()) { editorId= "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } else { editorId= desc.getId(); } IEditorPart editor; if (NewSearchUI.reuseEditor()) { editor= showWithReuse(file, wbPage, editorId, activate); } else { editor= showWithoutReuse(file, wbPage, editorId, activate); } if (editor instanceof ITextEditor) { ITextEditor textEditor= (ITextEditor) editor; textEditor.selectAndReveal(offset, length); } else if (editor != null) { showWithMarker(editor, file, offset, length); } return editor; }
IEditorDescriptor editorDesc = editorReg.getDefaultEditor(name, contentTypes[i]); editorDesc = overrideDefaultEditorAssociation(input, contentTypes[i], editorDesc); if ((editorDesc != null) && (editorDesc.isInternal())) return page.openEditor(input, editorDesc.getId()); editors = overrideEditorAssociations(input, null, editors); for(int i = 0 ; i < editors.length; i++) { if ((editors[i] != null) && (editors[i].isInternal())) return page.openEditor(input, editors[i].getId());
private ITextEditor openEditorReuse(Match marker) throws PartInitException { IWorkbenchPage page= SearchPlugin.getActivePage(); IFile file= (IFile) marker.getElement(); if (page == null) return null; ITextEditor textEditor= showOpenTextEditor(page, file); if (textEditor != null) return textEditor; String editorId= null; IEditorDescriptor desc= IDE.getDefaultEditor(file); if (desc != null && desc.isInternal()) editorId= desc.getId(); boolean isOpen= isEditorOpen(page, fEditor); boolean canBeReused= isOpen && !fEditor.isDirty() && !isPinned(fEditor); boolean showsSameInputType= fEditor != null && (editorId == null || fEditor.getSite().getId().equals(editorId)); if (canBeReused) { if (showsSameInputType) { fEditor.setInput(new FileEditorInput(file)); page.bringToTop(fEditor); return (ITextEditor) fEditor; } page.closeEditor(fEditor, false); fEditor= null; } return openNewTextEditor(file, page); }
if (descrptr.isInternal() && openEditors.length == 0){ IEditorPart part = page.openEditor(input, IDE.getEditorDescriptor(file).getId(), true, IWorkbenchPage.MATCH_INPUT); AbstractDecoratedTextEditor te = findTextEditorPart(page, part, input);
if (descrptr.isInternal() && openEditors.length == 0){ IEditorPart part = page.openEditor(input, IDE.getEditorDescriptor(file, true, true).getId(), true, IWorkbenchPage.MATCH_INPUT); AbstractDecoratedTextEditor te = findTextEditorPart(page, part, input);
} else if (desc.isInternal()) {