Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Lazy creating editors / Changes to getEditors().

Have appropriate bugs been opened in the affected components? Not all Eclipse 
developers are subscribed to this mailing list.

Also, were these changes included in today's (20020514) build?

Thanks,
- Jared

On Monday 13 May 2002 09:37 am, you wrote:
> In order to lazy create editors on startup some changes to org.eclipse.ui
> have happened. This changes will improve the startup time in case the user
> has many open editors and in case he has editors from different plugins.
>
> The API getEditors() was deprecated and the APIs getEditorReferences(),
> getDirtyEditors (convenience API) and findEditor(input) were added to
> IWorkbenchPage. To keep backward compatibility, getEditors() was changed
> to initialize/instanciate all editors before returning them. So
> getEditors() should be avoided otherwise the first caller will pay the
> time saved from the startup.
>
> The API getViews was deprecated as well. The intention is to lazy create
> views so that views hidden on a tab folder are not going to be
> instanciated until they are made visible. The API getViewReferences was
> added to IWorkbenchPage but the implementation has not changed yet.
>
> Here is a list of senders of getEditors() from Eclipse Platform and JDT. I
> have changed most of them in order to test it. It is important that these
> methods are changed specially if they get called on startup. Any operation
> that includes a call to getEditors may take seconds instead of
> milliseconds since it is going to activate plugins and create editors.
>
> Thanks.
> Eduardo.
>
> 1) run() - org.eclipse.ant.internal.ui.AntAction -> Use saveAllEditors
> instead.
> public void run() {
>         if (file == null)
>                 return;
>
>         // save the modified files if required by the user
>         if
> (AntUIPlugin.getPlugin().getPreferenceStore().getBoolean(IAntPreferenceCons
>tants.AUTO_SAVE)) {
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAl
>lEditors(false); }
>
>         Project project = extractProject(file);
>         if (project == null)
>                 return;
>
>         AntLaunchWizard wizard = new AntLaunchWizard(project,file);
>         wizard.setNeedsProgressMonitor(true);
>         WizardDialog dialog = new
> WizardDialog(AntUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindo
>w().getShell(),wizard); dialog.create();
>         dialog.open();
> }
>
> 2) getDirtyEditors() - org.eclipse.compare.internal.CompareUIPlugin: Use
> getDirtyEditors() instead of getEditors();
>         public static IEditorPart[] getDirtyEditors();
>
> 3) getDocument(IFile) - org.eclipse.compare.internal.EditionAction: Use
> findEditor instead
>         private IDocument getDocument(IFile file) {
>                 IWorkbench wb= PlatformUI.getWorkbench();
>                 if (wb == null)
>                         return null;
>                 IWorkbenchWindow[] ws= wb.getWorkbenchWindows();
>                 if (ws == null)
>                         return null;
>
>                 FileEditorInput test= new FileEditorInput(file);
>
>                 for (int i= 0; i < ws.length; i++) {
>                         IWorkbenchWindow w= ws[i];
>                         IWorkbenchPage[] wps= w.getPages();
>                         if (wps != null) {
>                                 for (int j= 0; j < wps.length; j++) {
>                                         IWorkbenchPage wp= wps[j];
>                                         IEditorPart ep =
> wp.findEditor(test);
>                                         if (ep != null && ep instanceof
> ITextEditor) {
>                                                 ITextEditor te=
> (ITextEditor) ep;
>                                                 IDocumentProvider dp=
> te.getDocumentProvider();
>                                                 if (dp != null) {
>                                                         IDocument doc=
> dp.getDocument(ep.getEditorInput());
>                                                         if (doc != null)
>                                                         return doc;
>                                                 }
>                                         }
>                                 }
>                         }
>                 }
>                 return null;
>         }
>
>
> 4) openEditorAndSetMarker(IEditorInput, String, int, int, int) -
> org.eclipse.debug.internal.ui.views.LaunchView (2 matches)
>         page.getEditorReferences();
> 5) saveState(IMemento) - org.eclipse.debug.internal.ui.views.LaunchView
>         page.getEditorReferences();
> 6) linkToEditor(IStructuredSelection) -
> org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart
>         create inputs and use findEditor(IEditorInput) instead
> 7) isOpenInEditor(Object) -
> org.eclipse.jdt.internal.ui.javaeditor.EditorUtility
>         public static IEditorPart isOpenInEditor(Object inputElement) {
>                 IEditorInput input= null;
>
>                 try {
>                         input= getEditorInput(inputElement);
>                 } catch (JavaModelException x) {
>                         JavaPlugin.log(x.getStatus());
>                 }
>
>                 if (input != null) {
>                         IWorkbenchPage p=
> JavaPlugin.getDefault().getActivePage();
>                         if (p != null) {
>                                 return p.findEditor(input);
>                         }
>                 }
>
>                 return null;
>         }
> 8) getDirtyEditors() - org.eclipse.jdt.internal.ui.JavaPlugin
>         Use getDirtyEditors instead of getEditors()
> 9) linkToEditor(IStructuredSelection) -
> org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart
>         Use findEditor instead
> 10) selectAndReveal(Object) -
> org.eclipse.jdt.internal.ui.refactoring.RefactoringSupportFactory.RenameSup
>port IEditorReference refs[] = page.getEditorReferences();
>         for (int i = 0; i < refs.length; i++) {
>                 if(refs[i].getPart(false) != null)
>                         parts.add(refs[i].getPart(false));
>         }
> 11) showInEditor(IMarker, IWorkbenchPage, IEditorInput, String) -
> org.eclipse.jdt.internal.ui.search.GotoMarkerAction
>         private void showInEditor(IMarker marker, IWorkbenchPage page,
> IEditorInput input, String editorId) {
>                 IEditorPart editor= page.findEditor(input);
>                 if (editor == null) {
>                         if (fEditor != null && !fEditor.isDirty())
>                                         page.closeEditor(fEditor, false);
>                         try {
>                                 editor= page.openEditor(input, editorId,
> false);
>                         } catch (PartInitException ex) {
>                                 ExceptionHandler.handle(ex,
> SearchMessages.getString("Search.Error.openEditor.title"),
> SearchMessages.getString("Search.Error.openEditor.message"));
> //$NON-NLS-2$ //$NON-NLS-1$
>                                 return;
>                         }
>                 } else {
>                         page.bringToTop(editor);
>                 }
>                 if (editor != null) {
>                         editor.gotoMarker(marker);
>                         fEditor = editor;
>                 }
>         }
> 12) getEditors() - org.eclipse.jdt.internal.ui.search.SearchUtil
>         public static IEditorPart[] getEditors() {
>                 final Set inputs= new HashSet(7);
>                 final List result= new ArrayList(0);
>                 IWorkbench workbench=
> JavaPlugin.getDefault().getWorkbench();
>                 IWorkbenchWindow[] windows=
> workbench.getWorkbenchWindows();
>                 for (int i= 0; i < windows.length; i++) {
>                         IWorkbenchPage[] pages= windows[i].getPages();
>                         for (int x= 0; x < pages.length; x++) {
>                                 IEditorReference[] editors=
> pages[x].getEditorReferences();
>                                 for (int z= 0; z < editors.length; z++) {
>                                         IEditorPart editor=
> editors[z].getEditor(false);
>                                         if(editor == null)
>                                                 continue;
>                                         IEditorInput input=
> editor.getEditorInput();
>                                         if (!inputs.contains(input)) {
>                                                 inputs.add(input);
>                                                 result.add(editor);
>                                         }
>                                 }
>                         }
>                 }
>                 return (IEditorPart[])result.toArray(new
> IEditorPart[result.size()]);
>         }
> 13) getDirtyEditors() -
> org.eclipse.search.internal.core.text.TextSearchVisitor
>         Use getDirtyEditors() instead of getEditors()
> 14) showWithReuse(IMarker) -
> org.eclipse.search.internal.ui.text.GotoMarkerAction
>         Use findEditor instead of getEditors();
> _______________________________________________
> platform-ui-dev mailing list
> platform-ui-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ui-dev


Back to the top