Bug 32962 - [Editor Mgmt] API which allows more selective save of dirty editors
Summary: [Editor Mgmt] API which allows more selective save of dirty editors
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P4 enhancement (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Michael Van Meekeren CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
: 41857 (view as bug list)
Depends on:
Blocks: 40338
  Show dependency tree
 
Reported: 2003-02-25 09:48 EST by Michael Valenta CLA
Modified: 2004-05-07 17:49 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Valenta CLA 2003-02-25 09:48:25 EST
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.
Comment 1 Michael Valenta CLA 2003-02-25 11:37:25 EST
It may be desirable to also retrict the operation to selected projects or 
resources (i.e. only htose involved in the operation).
Comment 2 Nick Edgar CLA 2003-03-03 21:50:43 EST
There are no plans for the UI team to work on this defect until higher 
priority items are addressed. 
Comment 3 Michael Valenta CLA 2003-08-22 10:10:46 EDT
*** Bug 41857 has been marked as a duplicate of this bug. ***
Comment 4 Nick Edgar CLA 2004-05-07 11:08:25 EDT
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);
        }
Comment 5 Michael Van Meekeren CLA 2004-05-07 17:49:08 EDT
done

See IDE.saveAllEditors(IResource[], boolean)

You can use an array of resources rather then a set of projects,  this is more 
flexible.