Community
Participate
Working Groups
A View part that implements ISaveablePart should be consulted about it's state before it is closed. This would give the view to give the user the chance to veto the event. This should be supported for all close events, including Workbench shutdown.
Stefan, Matt is trying to work around this problem in 3.0. Is there any way he can request a view's dirty state from the presentation?
Matt is investigating for 3.0.1. Behaviour should depend on an internal pref to prevent unwanted change in behaviour for any existing views implementing ISaveablePart.
Created attachment 14303 [details] Just a prelim patch for feedback I did some cut and paste from EditorManager. Not optimal, but it gets the job done with minimal modifications. I have not done a complete regression test on this patch. I'm posting it to get some initial feedback.
I'm OK with the patch overall. Ideally the methods copied from EditorManager could be shared somewhere, either in WorkbenchPage (already bloated) or some new helper class, though I would want to keep the EditorManager.savePart method there in 3.0.1 -- it could forward as needed. Stefan, could you please review Matt's patch as well? Do you have thoughts on how best to share the code?
Actually, in order to avoid unwanted change in behaviour in 3.0.1 for other views implementing ISaveablePart, we should check an internal preference as to whether to prompt on dirty view close. Default would be false.
I've posted the following to the eclipse.platform newsgroup: RFC: Close prompt for views that implement ISaveablePart In Eclipse 2.1, the Workbench added the ISaveablePart interface, allowing views to participate in the open/modify/save lifecycle usually reserved for editors. This was initially done to allow people making modifications in the Synchronize view to use Ctrl+S or File > Save to save their changes. However, we never added the support to prompt to save any unsaved changes when closing such a view, in the same way that editors do. This is something we're considering adding for 3.1, and possibly 3.0.1. For more details, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=72114 Question: does anybody in the community have views that implement ISaveablePart, and would they want this change of behaviour?
See bug 10234 for the original work on ISaveablePart. See also bug 45248.
See also bug 71701.
Created attachment 14324 [details] updated to include the use of a helper class to share code
nick, any response from the NG or other? I'd like to put this in today or mark as 3.1 or other if not.
Patch reviewed and released into 3.0.1 and head streams. Also added test in IWorkbenchPageTest.testHideSaveableView(). To support this test, there's a new test harness method: SaveableHelper.testSetAutomatedResponse(int), which the savePart method checks.
Verified in M20040908, using modified browser example.
Hi, I just noticed this change in save behavior. I've opened a side-effect bug, Bug 74028.
Need to reopen this one due to bug 74028. Will add the pref as described in comment #2.
I've released an updated patch to both streams, along with improved test coverage: in class Perspective: public boolean canCloseView(IViewPart view) { if (PrefUtil.getInternalPreferenceStore().getBoolean("fix72114")) { if (view instanceof ISaveablePart) { ISaveablePart saveable = (ISaveablePart)view; if (saveable.isSaveOnCloseNeeded()) { IWorkbenchWindow window = view.getSite().getWorkbenchWindow(); return SaveableHelper.savePart(saveable, view, window, true); } } } return true; } Matt, you'll need to add the following to your plugin_customization.ini file: org.eclipse.ui.workbench/fix72114=true
Verified in M20040916-1125.
Matt and Amy, can you please also verify this in the M20040616-1125 build?
I have verified (loading org.eclipse.ui.workbench from the R3_0_maintenance branch) that without org.eclipse.ui.workbench/fix72114=true I dont get prompt dialog. With it && isSaveOnCloseNeeded return true I get the dialog. With pref && isSaveOnCloseNeeded return false, I don't get dialog. Thanks!
It is critical that our application be able to specify a custom prompt. Reusing the Eclipse "save resource" prompt is not always adequate. Patch to follow.
Created attachment 15333 [details] allows for custom prompt dialog
Matt, please open a separate bug report rather than reopening reports for fixes that have shipped.
re-closing as verified
nick, do you want to mention this in New and Noteworthy for M3
I don't think it's major enough to mention, plus it still requires specifying org.eclipse.ui.workbench/fix72114=true to get this behaviour.
Has this been totally resolved in 3.0.2 or is still required to add a plugin_customization.ini file to the product with the org.eclipse.ui.workbench/fix72114=true line added to it? I have a view that implements ISaveablePart and it notifies the workbench whenever the dirty state changes since I can see the workbench save icon getting enable. However, it does not seem to notify the workbench by calling ISaveablePart.isSaveOnCloseNeeded() and isDirty() as appropriate to determine whether to open the save dialog when the view is closed.
In 3.0.2, org.eclipse.ui.workbench/fix72114=true is still needed. This check has been removed in 3.1. Note that in 3.0.x, it only checks when the view is explicitly closed, not when the window is closed or the workbench is shut down. This has been fixed in 3.1.