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

Bug 262132

Summary: [EditorMgmt] Hitting close X should not send partActivated event
Product: [Eclipse Project] Platform Reporter: Sebastian Dietrich <Sebastian.Dietrich>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: daniel.kullmann, daniel_megert, gunnar, pwebster, raj.alagumalai, remy.suen
Version: 3.4.1Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Sebastian Dietrich CLA 2009-01-23 03:17:38 EST
Build ID: M20080911-1700

Steps To Reproduce:
1. Select "Link with Editor" in Package Explorer
2. Open a file (e.g. java source file) --> corresponding file gets selected in Package Explorer
3. Select another file in Package Explorer
4. Close the file
--> the now closed file is selected in Package Explorer


More information:
this is even more inconvenient when you e.g. have collapsed your package tree and close your files --> the package tree is no longer collapsed
Comment 1 Dani Megert CLA 2009-01-23 10:56:33 EST
This happens with other navigation views as well. The problem is that a partActivated is sent when closing the editor. This seems odd and not also not optimal regarding performance.
Comment 2 Eric Moffatt CLA 2009-01-26 15:15:05 EST
Note that this only seems to happen when there is only a single file open. When there is more than one file open it chooses another based on the activation history.

Dani, I think that its the Explorer that's being activated (since there are no currently open editors). Could you verify this ? If this is the cause of the partActivated event then maybe we should change the defect's title since in that case the part activation (of the explorer) is necessary.


Comment 3 Dani Megert CLA 2009-01-27 03:23:27 EST
Sorry Eric you are wrong: clicking on the X in the tab always activates the editor and sends an IPartListener2.partActivated(IWorkbenchPartReference) event for that editor.
Comment 4 Eric Moffatt CLA 2009-01-28 12:42:57 EST
Dani, that's why I asked...;-).

I'm still confused though, I've placed breakpoints in:

PartListenerList2 [line: 65] - firePartActivated(IWorkbenchPartReference)
WorkbenchPage [line: 620] - activatePart(IWorkbenchPart)

and neither BP gets triggered when I close a non-active editor using "X", what am I missing?
Comment 5 Dani Megert CLA 2009-01-29 04:33:42 EST
>Dani, that's why I asked...;-).
Sorry :-)

I guess I was also not 100% clear in my answer: you are right that only closing the last editor exposes the issue that hitting the [x] on the non-active editor tab activates the editor.

I've set the BP at same locations too and they get hit (and the part that gets activated is the CompilationUnitEditor that gets closed). I see two reasons why you don't see it:
1) we have different settings in our target workspace (mine is out of the box)
2) you are not on WindowsXP (though I see the same on Linux-GTK)

Here's the stack when the BP is hit on WindowsXP:

Thread [main] (Suspended (breakpoint at line 620 in WorkbenchPage))	
	WorkbenchPage.activatePart(IWorkbenchPart) line: 620	
	WorkbenchPage.setActivePart(IWorkbenchPart) line: 3518	
	WorkbenchPage.requestActivation(IWorkbenchPart) line: 3065	
	EditorPane(PartPane).requestActivation() line: 279	
	EditorPane.requestActivation() line: 98	
	PresentablePart.setFocus() line: 192	
	TabbedStackPresentation$1.handleEvent(TabFolderEvent) line: 94	
	DefaultTabFolder(AbstractTabFolder).fireEvent(TabFolderEvent) line: 270	
	DefaultTabFolder(AbstractTabFolder).fireEvent(int) line: 275	
	DefaultTabFolder(AbstractTabFolder).handleMouseDown(Point, MouseEvent) line: 345	
	AbstractTabFolder$3.mouseDown(MouseEvent) line: 79	
	TypedListener.handleEvent(Event) line: 179	
	EventTable.sendEvent(Event) line: 84	
	CTabFolder(Widget).sendEvent(Event) line: 1003	
	Display.runDeferredEvents() line: 3875	
	Display.readAndDispatch() line: 3470	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2388	
	Workbench.runUI() line: 2352	
	Workbench.access$4(Workbench) line: 2204	
	Workbench$5.run() line: 499	
	Realm.runWithDefault(Realm, Runnable) line: 333	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 492	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 113	
	EclipseAppHandle.run(Object) line: 194	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 368	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 556	
	Main.basicRun(String[]) line: 511	
	Main.run(String[]) line: 1270	
	Main.main(String[]) line: 1246	
Comment 6 Boris Bokowski CLA 2009-02-10 18:26:56 EST
*** Bug 261725 has been marked as a duplicate of this bug. ***
Comment 7 Boris Bokowski CLA 2009-02-10 18:27:13 EST
*** Bug 264166 has been marked as a duplicate of this bug. ***
Comment 8 Remy Suen CLA 2009-02-10 18:59:44 EST
(In reply to comment #5)
> Thread [main] (Suspended (breakpoint at line 620 in WorkbenchPage))     
>         WorkbenchPage.activatePart(IWorkbenchPart) line: 620    
>         WorkbenchPage.setActivePart(IWorkbenchPart) line: 3518  
>         WorkbenchPage.requestActivation(IWorkbenchPart) line: 3065      
>         EditorPane(PartPane).requestActivation() line: 279      
>         EditorPane.requestActivation() line: 98 
>         PresentablePart.setFocus() line: 192    
>         TabbedStackPresentation$1.handleEvent(TabFolderEvent) line: 94  
>         DefaultTabFolder(AbstractTabFolder).fireEvent(TabFolderEvent) line: 270 
>         DefaultTabFolder(AbstractTabFolder).fireEvent(int) line: 275    
>         DefaultTabFolder(AbstractTabFolder).handleMouseDown(Point, MouseEvent)
> line: 345

Since the trace leads down (or up) to handleMouseDown(Point, MouseEvent), I suspect this may be a duplicate of bug 258511. Dani?
Comment 9 Remy Suen CLA 2009-02-11 00:35:17 EST
(In reply to comment #8)
> Since the trace leads down (or up) to handleMouseDown(Point, MouseEvent), I
> suspect this may be a duplicate of bug 258511. Dani?

But I guess since bug 258511 is talking about the middle mouse button the patch on that bug won't actually solve the problem described on this bug... :o
Comment 10 Dani Megert CLA 2009-02-11 02:42:32 EST
>Since the trace leads down (or up) to handleMouseDown(Point, MouseEvent), I
>suspect this may be a duplicate of bug 258511. Dani?
Could be. This bug here is about single click on the [x] but it's similar the bug you mention and also similar to bug 60833: basically we should not activate the editor no matter what's done on/with the editor tab until something is done that really requires this.
Comment 11 Boris Bokowski CLA 2009-11-17 12:59:53 EST
Remy is now responsible for watching the [EditorMgmt] component area.
Comment 12 Dani Megert CLA 2011-01-19 11:22:50 EST
*** Bug 334774 has been marked as a duplicate of this bug. ***
Comment 13 Lars Vogel CLA 2019-09-24 13:51:52 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.