Bug 147900 - [refactoring] Refactoring stops without an error if an open file can't be saved
Summary: [refactoring] Refactoring stops without an error if an open file can't be saved
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 149471 149469
Blocks:
  Show dependency tree
 
Reported: 2006-06-20 13:04 EDT by Dirk Baeumer CLA
Modified: 2007-06-22 13:09 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2006-06-20 13:04:20 EDT
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.
Comment 1 Markus Keller CLA 2006-06-30 10:49:51 EDT
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.
Comment 2 Markus Keller CLA 2006-07-03 11:20:24 EDT
See bug 149471 for the first proposed improvement (show unsaveable editors)
and bug 149462 for the second (do not save before starting refactorings).
Comment 3 Markus Keller CLA 2007-06-22 13:09:32 EDT
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.