Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 428664

Summary: [EditorMgmt] EditorPart#isSaveOnCloseNeeded() not called when closing Editor Parts via "Close All" or "Close Others"
Product: [Eclipse Project] Platform Reporter: Phil Beauvoir <p.beauvoir>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: emoffatt
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 8   
Whiteboard:

Description Phil Beauvoir CLA 2014-02-20 11:05:36 EST
This is a continuation of Bug #372992 and Bug #411465.

If I have two or more Editor Parts open and then select "Close All" or "Close Others" from the contextual menu on an Editor Part's tab then EditorPart#isSaveOnCloseNeeded() is *not* called. As a result a "Save Resources" dialog appears inviting me to save the "dirty" resources.

In my app I need to return false as I don't want this dialog to appear.

I'm trying to get my Eclipse 3.8.x RCP application to work in Compatibility mode for Eclipse 4.4.x.

This works fine in Eclipse 3.8.2.
Comment 1 Phil Beauvoir CLA 2014-02-20 17:40:00 EST
This is a regression and has appeared in Integration Build id: I20140218-0800.

In Eclipse 4.4 M5 Build id: I20140123-1600 this all worked as expected, isSaveOnCloseNeeded() was called on closing Editor Parts in this way.

For information, the stack trace on a breakpoint at isSaveOnCloseNeeded() on my subclass was:

Thread [main] (Suspended (breakpoint at line 498 in AbstractDiagramEditor))	
	ArchimateDiagramEditor(AbstractDiagramEditor).isSaveOnCloseNeeded() line: 498	
	WorkbenchPage.saveSaveable(ISaveablePart, IWorkbenchPart, boolean, boolean) line: 3760	
	WorkbenchWindow$7.save(MPart, boolean) line: 563	
	PartServiceImpl.savePart(MPart, boolean) line: 1268	
	StackRenderer.closeSiblingParts(MPart, boolean) line: 1458	
	StackRenderer.access$6(StackRenderer, MPart, boolean) line: 1430	
	StackRenderer$18.widgetSelected(SelectionEvent) line: 1379	
	TypedListener.handleEvent(Event) line: 248	
	EventTable.sendEvent(Event) line: 84	
	Display.sendEvent(EventTable, Event) line: 4353	
	MenuItem(Widget).sendEvent(Event) line: 1061	
	Display.runDeferredEvents() line: 4172	
	Display.readAndDispatch() line: 3761	
	PartRenderingEngine$9.run() line: 1122	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1006	
	E4Workbench.createAndRunUI(MApplicationElement) line: 146	
	Workbench$5.run() line: 615	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 566	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150	
	Application.start(IApplicationContext) line: 78	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 109	
	EclipseAppLauncher.start(Object) line: 80	
	EclipseStarter.run(Object) line: 372	
	EclipseStarter.run(String[], Runnable) line: 226	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 606	
	Main.invokeFramework(String[], URL[]) line: 636	
	Main.basicRun(String[]) line: 591	
	Main.run(String[]) line: 1450	
	Main.main(String[]) line: 1426

But this is not called in I build I20140218-0800
Comment 2 Phil Beauvoir CLA 2014-02-20 18:03:13 EST
Looking through recent changes I found this:

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=14734da604e6240048c4d62ef1279c9c7787d6a2

related to a recent fix for:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=396318
Save Resources dialog missing when selecting Close All from editor tab

Is this it?
Comment 3 Paul Elder CLA 2014-02-25 10:24:15 EST
(In reply to comment #2)
> Looking through recent changes I found this:
> 
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=14734da604e6240048c4d62ef1279c9c7787d6a2
> 
> related to a recent fix for:
> 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=396318
> Save Resources dialog missing when selecting Close All from editor tab
> 
> Is this it?

No. Close All and Close Others still do not call isSaveOnCloseNeeded().
Comment 4 Phil Beauvoir CLA 2014-02-25 11:00:08 EST
(In reply to Paul Elder from comment #3)
> (In reply to comment #2)
> > Looking through recent changes I found this:
> > 
> > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=14734da604e6240048c4d62ef1279c9c7787d6a2
> > 
> > related to a recent fix for:
> > 
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=396318
> > Save Resources dialog missing when selecting Close All from editor tab
> > 
> > Is this it?
> 
> No. Close All and Close Others still do not call isSaveOnCloseNeeded().

That's what I mean isn't it? If Close All and Close Others do not call isSaveOnCloseNeeded() then that's the cause of this bug. In 3.8 they do.
Comment 5 Phil Beauvoir CLA 2014-02-26 01:50:12 EST
(In reply to Paul Elder from comment #3)
> (In reply to comment #2)
> > Looking through recent changes I found this:
> > 
> > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=14734da604e6240048c4d62ef1279c9c7787d6a2
> > 
> > related to a recent fix for:
> > 
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=396318
> > Save Resources dialog missing when selecting Close All from editor tab
> > 
> > Is this it?
> 
> No. Close All and Close Others still do not call isSaveOnCloseNeeded().

Perhaps I didn't make myself clear.

I mean, is this recent change what caused a regression so that Close All and Close Others do not call isSaveOnCloseNeeded()
Comment 6 Paul Elder CLA 2014-02-26 11:27:42 EST
(In reply to Phillipus B from comment #5)

> Perhaps I didn't make myself clear.
> 
> I mean, is this recent change what caused a regression so that Close All and
> Close Others do not call isSaveOnCloseNeeded()

Ah, I understand. Yes, the fix for bug 396318 appears to have caused this regression. Ironically, that bug was trying to delegate from the e4 UI back more completely to the 3.x compatibility layer so that the correct save dialogs would display. But, it seems that code doesn't respect ISaveablePart, ISaveablePart2 or any of the Saveables infrastructure found in 3.x. I am working on it.
Comment 7 Phil Beauvoir CLA 2014-02-27 08:19:55 EST
(In reply to Paul Elder from comment #6)
> (In reply to Phillipus B from comment #5)
> 
> > Perhaps I didn't make myself clear.
> > 
> > I mean, is this recent change what caused a regression so that Close All and
> > Close Others do not call isSaveOnCloseNeeded()
> 
> Ah, I understand. Yes, the fix for bug 396318 appears to have caused this
> regression. Ironically, that bug was trying to delegate from the e4 UI back
> more completely to the 3.x compatibility layer so that the correct save
> dialogs would display. But, it seems that code doesn't respect
> ISaveablePart, ISaveablePart2 or any of the Saveables infrastructure found
> in 3.x. I am working on it.

That's superb, thanks. :-)
Comment 8 Phil Beauvoir CLA 2014-03-03 04:50:40 EST
A polite enquiry - will it be fixed for M6?
Comment 9 Paul Elder CLA 2014-03-03 08:56:53 EST
(In reply to Phillipus B from comment #8)
> A polite enquiry - will it be fixed for M6?

Unfortunately, it did not get into M6 (contributions shut down last week).
Comment 10 Phil Beauvoir CLA 2014-03-03 09:06:28 EST
(In reply to Paul Elder from comment #9)
> (In reply to Phillipus B from comment #8)
> > A polite enquiry - will it be fixed for M6?
> 
> Unfortunately, it did not get into M6 (contributions shut down last week).

OK. I appreciate that. Thanks for looking at it. :-)
Comment 11 Phil Beauvoir CLA 2014-04-08 06:20:16 EDT
Target 4.4 M7 removed? Will it be fixed for 4.4 at all?
Comment 12 Paul Webster CLA 2014-04-08 09:59:41 EDT
(In reply to Phillipus B from comment #11)
> Target 4.4 M7 removed? Will it be fixed for 4.4 at all?

No

PW
Comment 13 Phil Beauvoir CLA 2014-04-08 10:15:56 EDT
(In reply to Paul Webster from comment #12)
> (In reply to Phillipus B from comment #11)
> > Target 4.4 M7 removed? Will it be fixed for 4.4 at all?
> 
> No
> 
> PW

I'm left wondering why. Seems strange that it seems to be a regression and wont be fixed.
Comment 14 Paul Webster CLA 2014-04-08 10:23:27 EDT
Resources.  The people that could fix this bug are either busy or have moved on.

If you contribute a fix we would look at it for Luna, but I understand that it's not easy to fix.

PW
Comment 15 Phil Beauvoir CLA 2014-06-25 11:21:22 EDT
(In reply to Paul Webster from comment #14)
> Resources.  The people that could fix this bug are either busy or have moved
> on.
> 
> If you contribute a fix we would look at it for Luna, but I understand that
> it's not easy to fix.
> 
> PW

I'm sorry but I wouldn't know where to start on fixing this.
Comment 16 Eric Moffatt CLA 2014-07-08 13:33:37 EDT
Just to add some more info as to why this turns out to be more difficult to fix than it seems...

The problem is that the Close & Close Others are pure 'e4' menu elements, created by the stack renderer (i.e. not a part of the normal IDE Commands infrastructure). This makes it difficult to have them access IDE-specific code as part of their implementation.

We'd either have to move the save code out into the 'e4' layer or provide a new mechanism to allow for contributions (and *overrides*) to the CTabItem's context menu...
Comment 17 Wojciech Sudol CLA 2014-09-17 07:30:58 EDT
I've verified in Eclipse 4.4.1 RC4 and 4.5 M2 that this issue has been fixed by changes made in the fix for the bug 410749.

Phil, could you verify and confirm it works as expected for you?
Comment 18 Phil Beauvoir CLA 2014-09-17 08:44:19 EDT
(In reply to Wojciech Sudol from comment #17)
> I've verified in Eclipse 4.4.1 RC4 and 4.5 M2 that this issue has been fixed
> by changes made in the fix for the bug 410749.
> 
> Phil, could you verify and confirm it works as expected for you?

Wojciech:

Thank-you, thank-you, thank-you, thank-you, thank-you, thank-you, thank-you, thank-you, thank-you, thank-you!

Verified and confirmed.

:-)
Comment 19 Wojciech Sudol CLA 2014-09-17 09:05:16 EDT
(In reply to Phil Beauvoir from comment #18)
> Verified and confirmed.

Thank you for the verification. Closing as 'worksforme'.