Community
Participate
Working Groups
RC5 - open an editor and make the content dirty. Ensure that saving the editor will not work. The corresponding method returns false (see below). - enable automatic save for dirty editors when executing a refactoing - try to execute a refactoring. Observe: you get a busy cursor for some time and then nothing else happens. The problematic code is in RefactoringSaveHelper: if (!JavaPlugin.getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false)) return false; Two possible imrpovements: - the refactoring should present a dialog to the user which file couldn't be save and should allow to continue the operation - the file I had trouble with was totally unrelated to refactoring. So it could be ignored during the save operation.
The refactoring is correctly cancelled when saveAllEditors(..) returns false. How did you "ensure that saving the editor does not work"? I tried it by opening a dirty file with MS Word Viewer, but I got an error dialog telling that the file was locked. Your problem seems to depend on another cause for a failing save.
See bug 149471 for the first proposed improvement (show unsaveable editors) and bug 149462 for the second (do not save before starting refactorings).
There's actually no proper way for an editor to not save its file without informing the user. ISaveablePart.doSave(IProgressMonitor) has no return value and throws no exceptions, so implementors are required to inform the user if they did not succeed by showing a dialog and invoking setCanceled(true). Callers of doSave(..), including IWorkbench#saveAllEditors(..) must not show a dialog when a save operation was canceled. If your editor does not show a dialog when it fails to perform the save, then this is a bug that you editor must fix, see also bug 149469.