Community
Participate
Working Groups
Currently, the UI provides the following method to ensure that any dirty editors are saved before an operation. okToContinue = PlatformUI.getWorkbench().saveAllEditors(confirm) From a repository providers standpoint, it would be nice to provide API which allows the command to be narrowed down to a subset of the projects in the workbench (i.e. the projects that are shared with a particular repository type). This is made more complicated by the possibility of a linked resource in one project being a member of another project that is shared with a repository. If the linked resource has a dirty editor open, it would still be of interest to the repository provider.
It may be desirable to also retrict the operation to selected projects or resources (i.e. only htose involved in the operation).
There are no plans for the UI team to work on this defect until higher priority items are addressed.
*** Bug 41857 has been marked as a duplicate of this bug. ***
If we do this, it needs to go in the IDE layer since it's specific to resources. The code snippet is: ArrayList dirtyFiles = new ArrayList(); IWorkbenchWindow[] windows = PlatformUI.getWorkbench ().getWorkbenchWindows(); for (int i = 0; i < windows.length; i++) { IWorkbenchWindow window = windows[i]; IWorkbenchPage[] pages = window.getPages(); for (int j = 0; j < pages.length; j++) { IWorkbenchPage page = pages[j]; IEditorPart[] dirtyEditors = page.getDirtyEditors(); for (int k = 0; k < dirtyEditors.length; k++) { IEditorPart part = dirtyEditors[k]; IFile file = (IFile) part.getEditorInput().getAdapter (IFile.class); if (file != null) { dirtyFiles.add(file); } } } } for (Iterator i = dirtyFiles.iterator(); i.hasNext();) { IFile element = (IFile) i.next(); System.out.println(element); }
done See IDE.saveAllEditors(IResource[], boolean) You can use an array of resources rather then a set of projects, this is more flexible.