user3387395
user3387395

Reputation: 11

Save dirty editors in Eclipse

We have developed an Eclipse RCP Applicatoin. We have a requirement to check for all the dirty editors and prompt the user to save the same before we launch our dialog.

Please let me know if we have any reusable dialog to achieve the same.

Thanks in Advance, Harish

Upvotes: 0

Views: 1620

Answers (2)

Matthias
Matthias

Reputation: 2738

PlatformUI.getWorkbench().saveAllEditors(confirm);

Saves all dirty editors in the workbench. Opens a dialog to prompt the user if confirm is true

Source: http://www.eclipse.org/forums/index.php/t/95433/ and javadoc

Upvotes: 1

greg-449
greg-449

Reputation: 111142

Use org.eclipse.ui.ide.IDE.saveAllEditors:

IResource [] resources = array of IFile, IFolder, IProject 

boolean ok = IDE.saveAllEditors(resources, confirm);

From the JavaDoc:

Save all dirty editors in the workbench whose editor input is a child resource of one of the IResource's provided. Opens a dialog to prompt the user if confirm is true. Return true if successful. Return false if the user has canceled the command.

Upvotes: 0

Related Questions