Bug 334937 - [api] support cancelling the entire task switch when user cancels dirty editor save
Summary: [api] support cancelling the entire task switch when user cancels dirty edito...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 3.16   Edit
Assignee: Chris Poon CLA
QA Contact:
URL:
Whiteboard: effort=3;
Keywords: contributed, noteworthy
Depends on:
Blocks:
 
Reported: 2011-01-20 13:58 EST by Robert Elves CLA
Modified: 2015-05-21 15:03 EDT (History)
3 users (show)

See Also:


Attachments
proof of concept (5.11 KB, patch)
2012-07-17 16:30 EDT, Sam Davis CLA
no flags Details | Diff
mylyn/context/zip (95.22 KB, application/octet-stream)
2012-07-17 16:30 EDT, Sam Davis CLA
no flags Details
proof of concept (5.13 KB, patch)
2012-07-19 18:57 EDT, Sam Davis CLA
no flags Details | Diff
proof of concept (5.27 KB, patch)
2012-10-22 19:34 EDT, Sam Davis CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Elves CLA 2011-01-20 13:58:04 EST
When user's switch tasks with a dirty edtior still open, they are presented with a warning asking to save or cancel. Often time the user was unaware of the editor being dirty so wants to check what is going on before switching the task so presses Cancel.  Unfortunately, the task still switches (against expectations) but at least the editor is left open (but now being edited and polluting the wrong task context).  It seems like the best solution here would be to test for open dirty editors upon task switching and present our own, more informative dialog that upon canceling, actually cancels the task switch and focuses the dirty editor.
Comment 1 Steffen Pingel CLA 2011-08-11 07:52:58 EDT
Not sure if that's supported by the workbench API. Shawn?
Comment 2 Shawn Minto CLA 2011-08-25 11:27:38 EDT
I dont know if this is supported either.  Would have to look into this further, but I have had this thought in the past as well as cancel seems that it should cancel deactivation.
Comment 3 Sam Davis CLA 2012-07-13 17:23:04 EDT
It's hard to imagine this not being supported. I think we'd just have to go through all open editors calling IEditorPart.isDirty.
Comment 4 Sam Davis CLA 2012-07-17 16:30:22 EDT
Created attachment 218837 [details]
proof of concept

We might want to create a different API, e.g. an extension point for adding a new kind of listener, but this works well.
Comment 5 Sam Davis CLA 2012-07-17 16:30:25 EDT
Created attachment 218838 [details]
mylyn/context/zip
Comment 6 Sam Davis CLA 2012-07-19 18:57:48 EDT
Created attachment 218961 [details]
proof of concept
Comment 7 Sam Davis CLA 2012-10-02 16:40:13 EDT
I've been using this for a couple of months and I find it to be an improvement.
Comment 8 Sam Davis CLA 2012-10-22 19:34:51 EDT
Created attachment 222661 [details]
proof of concept
Comment 9 Tomasz Zarna CLA 2013-06-18 10:35:05 EDT
Sam, do you plan to work on this or can I take it over?
Comment 10 Sam Davis CLA 2013-06-18 14:03:24 EDT
Feel free to take it over. I've created the following reviews:

13879: 334937: provide API for canceling a task switch [I77eb930d]
https://git.eclipse.org/r/#/c/13879/

13880: 334937: [context] support canceling the entire task switch when user cancels dirty editor save [Ifa96cc89]
https://git.eclipse.org/r/#/c/13880/
Comment 11 Sam Davis CLA 2014-12-08 14:48:37 EST
I've been running on those reviews for a long time and it's an improvement, but one change I'd like to make is to not show the dialog when the only dirty editor is the task editor for the active task (that is, just show the dialog asking the user to save, but don't ask if they really want to cancel the task switch).
Comment 12 Sam Davis CLA 2015-05-06 14:38:10 EDT
I'd like the dialog to have the following options:

Deactivate Task and Save All | Deactivate and Save Some... | Cancel
Comment 13 Chris Poon CLA 2015-05-06 17:37:36 EDT
I've added an additional option "Deactivate Task and Save All" which will immediately save everything that is dirty.  There is an additional quirk where if you try to cancel a save on deactivation for only one dirty task (which is also the deactivated task), another save dialog would appear.  Looking into that now.
Comment 14 Sam Davis CLA 2015-05-21 15:03:24 EDT
Looks great! The changes have been merged:

47904: 334937: provide API for canceling a task switch [I0962f312]
https://git.eclipse.org/r/#/c/47904/

47669: 334937: support cancelling the entire task switch when user cancels dirty editor save [I9d874250]
https://git.eclipse.org/r/#/c/47669/