下面列出了org.eclipse.ui.IEditorRegistry#isSystemExternalEditorAvailable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void openFile(IFile file) {
IEditorRegistry registry = PlatformUI.getWorkbench()
.getEditorRegistry();
if (registry.isSystemExternalEditorAvailable(file.getName())) {
/**
* in case of opening the exported file from an other thread e.g. in
* case of listening to an IResourceChangeEvent
*/
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
try {
page.openEditor(new FileEditorInput(file),
IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
} catch (PartInitException e) {
DotActivatorEx.logError(e);
}
}
});
}
}
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;
}
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$
}