Java Code Examples for org.eclipse.ui.IEditorDescriptor#getId()
The following examples show how to use
org.eclipse.ui.IEditorDescriptor#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditorOpener.java From typescript.java with MIT License | 8 votes |
public IEditorPart openAndSelect(IWorkbenchPage wbPage, IFile file, int offset, int length, boolean activate) throws PartInitException { String editorId= null; IEditorDescriptor desc= IDE.getEditorDescriptor(file); 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; }
Example 2
Source File: N4JSApplicationWorkbenchWindowAdvisor.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void updateDefaultEditorMappingIfAbsent() { final EditorRegistry registry = (EditorRegistry) WorkbenchPlugin.getDefault().getEditorRegistry(); for (final IFileEditorMapping editorMapping : registry.getFileEditorMappings()) { final IEditorDescriptor defaultEditor = editorMapping.getDefaultEditor(); if (null == defaultEditor) { final String extension = editorMapping.getExtension(); LOGGER.info("No default editor is associated with files with extension: '." + extension + "'."); final IEditorDescriptor defaultTextEditor = registry.findEditor(DEFAULT_TEXT_EDITOR_ID); if (null != defaultTextEditor) { ((FileEditorMapping) editorMapping).setDefaultEditor(defaultTextEditor); String editorName = defaultTextEditor.getLabel(); if (null == editorName) { editorName = defaultTextEditor.getId(); } if (null != editorName) { LOGGER.info("Associated files with extension " + extension + " with '" + editorName + "'."); } } } } registry.saveAssociations(); PrefUtil.savePrefs(); }
Example 3
Source File: SVNConflictResolver.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private String getEditorId(IFileStore file) { IWorkbench workbench = PlatformUI.getWorkbench(); IEditorRegistry editorRegistry= workbench.getEditorRegistry(); IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(file.getName(), getContentType(file)); // check the OS for in-place editor (OLE on Win32) if (descriptor == null && editorRegistry.isSystemInPlaceEditorAvailable(file.getName())) descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID); // check the OS for external editor if (descriptor == null && editorRegistry.isSystemExternalEditorAvailable(file.getName())) descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); if (descriptor != null) return descriptor.getId(); return EditorsUI.DEFAULT_TEXT_EDITOR_ID; }
Example 4
Source File: EditorUtil.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Open a file in an editor and return the opened editor part.<br> * This method will try to open the file in an internal editor, unless there is no editor descriptor assigned to * that file type. * * @param file * @return The {@link IEditorPart} that was created when the file was opened; Return null in case of an error */ public static IEditorPart openInEditor(File file) { // NOTE: Moved from PHP's EditorUtils if (file == null) { IdeLog.logError(CommonEditorPlugin.getDefault(), "Error open a file in the editor", new IllegalArgumentException("file is null")); //$NON-NLS-1$ //$NON-NLS-2$ return null; } try { URI uri = file.toURI(); IEditorDescriptor desc = getEditorDescriptor(uri); String editorId = (desc == null) ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID : desc.getId(); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); return IDE.openEditor(page, uri, editorId, true); } catch (Exception e) { IdeLog.logError(CommonEditorPlugin.getDefault(), "Error open a file in the editor", e); //$NON-NLS-1$ } return null; }
Example 5
Source File: OpenJavaSourceAction.java From birt with Eclipse Public License 1.0 | 6 votes |
private String getEditorId( IFileStore file ) { IWorkbench workbench = window.getWorkbench( ); IEditorRegistry editorRegistry = workbench.getEditorRegistry( ); IEditorDescriptor descriptor = editorRegistry.getDefaultEditor( file.getName( ), getContentType( file ) ); // check the OS for in-place editor (OLE on Win32) if ( descriptor == null && editorRegistry.isSystemInPlaceEditorAvailable( file.getName( ) ) ) { descriptor = editorRegistry.findEditor( IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID ); } // check the OS for external editor if ( descriptor == null && editorRegistry.isSystemExternalEditorAvailable( file.getName( ) ) ) { descriptor = editorRegistry.findEditor( IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID ); } return ( descriptor == null ) ? "" : descriptor.getId( ); //$NON-NLS-1$ }
Example 6
Source File: EditorOpener.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public IEditorPart openAndSelect(IWorkbenchPage wbPage, IFile file, int offset, int length, boolean activate) throws PartInitException { String editorId = null; IEditorDescriptor desc = IDE.getEditorDescriptor(file); 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; }
Example 7
Source File: AbapGitStagingService.java From ADT_Frontend with MIT License | 5 votes |
private String getEditorId(String fileName) { if (fileName.endsWith("xml")) { //$NON-NLS-1$ //if file type is .xml, return the associated XML editor IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor desc = editorReg.getDefaultEditor(fileName, Platform.getContentTypeManager().findContentTypeFor(fileName)); if (desc != null) { return desc.getId(); } } //use eclipse default text editor for all other files return IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID; }
Example 8
Source File: CoreEditorUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static String getEditorID(IEditorInput input) throws PartInitException { Assert.isNotNull(input); IEditorDescriptor editorDescriptor; if (input instanceof IFileEditorInput) editorDescriptor= IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()); else { editorDescriptor= IDE.getEditorDescriptor(input.getName()); } return editorDescriptor.getId(); }
Example 9
Source File: OpenXMLResultsAction.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private static String getEditorId(File file) { IWorkbench workbench = PlatformUI.getWorkbench(); IEditorRegistry editorRegistry = workbench.getEditorRegistry(); IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(file.getName(), getContentType(file)); if (descriptor != null) { return descriptor.getId(); } return EditorsUI.DEFAULT_TEXT_EDITOR_ID; }
Example 10
Source File: GWTDebugModelPresentation.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public String getEditorId(IEditorInput input, Object inputObject) { IFileEditorInput fileEditorInput = AdapterUtilities.getAdapter(input, IFileEditorInput.class); if (fileEditorInput != null) { IEditorDescriptor editor = IDE.getDefaultEditor(fileEditorInput.getFile()); if (editor != null) { return editor.getId(); } } // If editor input isn't pointing to a file, we can't properly determine // the content type so delegate to the default implementation. return super.getEditorId(input, inputObject); }
Example 11
Source File: ViewLogCommandHandler.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @param filePath * TODO: we should really make this into a utility function, and have the Ruble::Editor.open method use * it. But I am giving up for now because Eclipse plugin dependencies drive me crazy! */ private void openEditorForFile(String filePath) { File file = new File(filePath); // Process an existing file. if (file.exists() && file.isFile()) { Path path = new Path(filePath); IFile fileForLocation = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDescriptor = null; if (fileForLocation == null) { IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(filePath); editorDescriptor = editorRegistry.getDefaultEditor(filePath, contentType); } else { editorDescriptor = editorRegistry.getDefaultEditor(filePath); } String editorId = (editorDescriptor == null) ? "com.aptana.editor.text" : editorDescriptor.getId(); //$NON-NLS-1$ try { IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file.toURI(), editorId, true); } catch (PartInitException e) { IdeLog.logError(UIPlugin.getDefault(), e); } } }
Example 12
Source File: EditorOpener.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private String getEditorID(IFile file) throws PartInitException { IEditorDescriptor desc = IDE.getEditorDescriptor(file); if (desc == null) { return PydevPlugin.getDefault().getWorkbench().getEditorRegistry() .findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId(); } return desc.getId(); }
Example 13
Source File: EditorOpener.java From typescript.java with MIT License | 4 votes |
private String getEditorID(IFile file) throws PartInitException { IEditorDescriptor desc= IDE.getEditorDescriptor(file); if (desc == null) return SearchPlugin.getDefault().getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId(); return desc.getId(); }