public static void openEditor ( String contents , String name ) { IWorkbenchWindow window = PlatformUI . getWorkbench ( ) . getActiveWorkbenchWindow ( ) ; IStorage storage = new StringStorage ( contents , name ) ; IStorageEditorInput input = new StringInput ( storage ) ; IWorkbenchPage page = window . getActivePage ( ) ; IEditorDescriptor desc = PlatformUI . getWorkbench ( ) . getEditorRegistry ( ) . getDefaultEditor ( name ) ; // If there is no editor associated with the given file name, we'll just // use the eclipse text editor as a default String editorId = desc != null ? desc . getId ( ) : "org.eclipse.ui.DefaultTextEditor" ; //$NON-NLS-1$ try { if ( page != null ) { page . openEditor ( input , editorId ) ; } } catch ( Exception e ) { Activator . getDefault ( ) . displayError ( IStatus . ERROR , e . getMessage ( ) , e , true ) ; } }
Opens a read - only in - memory editor .