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 String getEditorId(IFileStore fileStore) { IWorkbench workbench= fWindow.getWorkbench(); IEditorRegistry editorRegistry= workbench.getEditorRegistry(); IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(fileStore.getName()); if (descriptor != null) return descriptor.getId(); return EditorsUI.DEFAULT_TEXT_EDITOR_ID; }
private static String getEditorId(String fileName, IContentType type) { IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type); String id; if (descriptor == null || descriptor.isOpenExternal()) { id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } else { id = descriptor.getId(); } return id; }
public static IEditorDescriptor getDefaultEditor(IFileRevision revision) { String name= revision.getName(); // so far only the revision name is used to find the default editor try { return IDE.getEditorDescriptor(name); } catch (PartInitException e) { // Fallback to old way of getting the editor IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry(); return registry.getDefaultEditor(name); } }
private String getEditorId(IFileStore fileStore) { IWorkbench workbench= fWindow.getWorkbench(); IEditorRegistry editorRegistry= workbench.getEditorRegistry(); IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(fileStore.getName()); if (descriptor != null) return descriptor.getId(); return EditorsUI.DEFAULT_TEXT_EDITOR_ID; }
public ImageDescriptor getDefaultEditorImageDescriptor(String fileName) { if (fileName != null && workbench != null) { IEditorDescriptor defaultEditor = workbench.getEditorRegistry().getDefaultEditor(fileName); if (defaultEditor != null) { return defaultEditor.getImageDescriptor(); } else { return workbench.getEditorRegistry().getSystemExternalEditorImageDescriptor(fileName); } } return null; } }
private static String getEditorId(String fileName, IContentType type) { IEditorRegistry registry = PlatformUI.getWorkbench() .getEditorRegistry(); IEditorDescriptor descriptor = registry .getDefaultEditor(fileName, type); String id; if (descriptor == null || descriptor.isOpenExternal()) { id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } else { id = descriptor.getId(); } return id; }
public void widgetSelected(SelectionEvent e) { try { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchPage workbenchPage = workbench.getActiveWorkbenchWindow().getActivePage(); IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor( LifecycleMappingFactory.LIFECYCLE_MAPPING_METADATA_SOURCE_NAME); IEditorInput input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile( new File(mappingFilePath))); IDE.openEditor(workbenchPage, input, desc.getId()); } catch(PartInitException ex) { log.error(ex.getMessage(), ex); } } });
private void unsetRegistration(IFile file) { // If the default editor for this file is not the Struts config. editor, // then we're done. IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor userEditor = registry.getDefaultEditor(file.getFullPath().toString()); if ((userEditor == null) || !FacesConfigPlugin.FACES_CONFIG_EDITOR_ID.equals(userEditor.getId())) { traceFiner(file, "Not unsetting: Default already not Faces config. editor"); return; } // Make the Struts config. editor the default. traceFiner(file, "Unsetting."); IEditorDescriptor[] editors = registry.getEditors(file.getFullPath().toString()); if (editors.length > 1) { registry.setDefaultEditor(file.getFullPath().toString(), editors[1].getId()); } }
private String getEditorId(IFile file) { IWorkbench workbench = getWorkbench(); // If there is a registered editor for the file use it. IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor(file.getName()); if (desc == null) { // default editor desc = workbench.getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); } return desc.getId(); }
protected void openEditor(IFile file) throws PartInitException { IWorkbenchPage page = getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorDescriptor defaultEditor = getWorkbench().getEditorRegistry().getDefaultEditor(file.getFullPath().toString()); page.openEditor (new FileEditorInput(file), defaultEditor == null ? "org.eclipse.emf.codegen.ecore.genmodel.presentation.GenModelEditorID" : defaultEditor.getId()); } }
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 static String getEditorId(FileRevisionEditorInput editorInput, IContentType type) { String fileName= editorInput.getFileRevision().getName(); IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type); IDE.overrideDefaultEditorAssociation(editorInput, type, descriptor); String id; if (descriptor == null || descriptor.isOpenExternal()) { id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } else { id = descriptor.getId(); } return id; }
private String getEditorId() { if (fEditorId == null) { IWorkbench workbench= DebugUIPlugin.getDefault().getWorkbench(); // If there is a registered editor for the file use it. IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor(fFile.getName(), getFileContentType()); if (desc == null) { //default editor desc= workbench.getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); } fEditorId= desc.getId(); } return fEditorId; }
protected IEditorPart openDefaultEditor(IStorage storage, URI uri) throws PartInitException { XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(storage); IWorkbenchPage page = getWorkbench().getActiveWorkbenchWindow().getActivePage(); return IDE.openEditor(page, editorInput, PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor( uri.lastSegment()).getId()); }
public void run() { IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); IContentType contentType = contentTypeManager.findContentTypeFor(name); IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editor = editorRegistry.getDefaultEditor(name, contentType); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if(window != null) { IWorkbenchPage page = window.getActivePage(); if(page != null) { try { part[0] = page.openEditor(editorInput, editor.getId()); } catch(PartInitException ex) { openDialog(NLS.bind(Messages.OpenPomAction_33, editorInput.getName(), ex.toString())); } } } } });
/* private */String getEditorID(String fileName, InputStream contents) { IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench(); IEditorRegistry registry = workbench.getEditorRegistry(); IContentType type = null; if (contents != null) { try { type = Platform.getContentTypeManager().findContentTypeFor(contents, fileName); } catch (IOException e) { } } if (type == null) { type = Platform.getContentTypeManager().findContentTypeFor(fileName); } IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type); String id; if (descriptor == null) { id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } else { id = descriptor.getId(); } return id; }
/* private */String getEditorID(String fileName, InputStream contents) { IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench(); IEditorRegistry registry = workbench.getEditorRegistry(); IContentType type = null; if (contents != null) { try { type = Platform.getContentTypeManager().findContentTypeFor(contents, fileName); } catch (IOException e) { } } if (type == null) { type = Platform.getContentTypeManager().findContentTypeFor(fileName); } IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type); String id; if (descriptor == null) { id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$ } else { id = descriptor.getId(); } return id; }
public void run() { try { String editorId = null; IEditorDescriptor editor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(iFile.getLocation().toOSString(), iFile.getContentDescription().getContentType()); if (editor != null) { editorId = editor.getId(); } workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), editorId); } catch (PartInitException ex) { } catch (CoreException ex) { } } });