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

Bug 373529

Summary: [Compatibility] IPageListener's pageOpened(*) is sent out too early
Product: [Eclipse Project] Platform Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Oleg Besedin <ob1.eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, pwebster
Version: 4.2   
Target Milestone: 4.2 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Remy Suen CLA 2012-03-07 09:24:32 EST
An IPageListener is attached by the WorkbenchActionBuilder but it doesn't appear to be notified of events.

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java?id=844bbce93cf313a819b87c3ed48d1b5ff4a47e21#n268
Comment 1 Remy Suen CLA 2012-03-07 11:07:37 EST
The event was being sent, just a little too early.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=e1b2a24fdb25939d58ec89391aa2580be2ce04dd
Comment 3 Oleg Besedin CLA 2012-04-23 16:40:40 EDT
I think the original fix (moving notification) is good, but then it exposes a problem in Workbench.getActiveWorkbenchWindow()

For some reason this method in 4.x always creates a new workbench window (unless we are closing down).

That code has being added for Bug 333764 "[Compatibility] NPE thrown when shutting down with Acceleo's 'Result' view up".

Remy, do you remember by chance if that was done on purpose?
Comment 4 Remy Suen CLA 2012-04-23 17:00:47 EDT
(In reply to comment #3)
> For some reason this method in 4.x always creates a new workbench window
> (unless we are closing down).

Basically, we want the first call to getActiveWorkbenchWindow() to return something meaningful and is why we "always" instantiate a workbench window instance. If our startup story was improved this probably wouldn't be necessary.
Comment 5 Oleg Besedin CLA 2012-04-24 10:11:19 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > For some reason this method in 4.x always creates a new workbench window
> > (unless we are closing down).
> 
> Basically, we want the first call to getActiveWorkbenchWindow() to return
> something meaningful and is why we "always" instantiate a workbench window
> instance. If our startup story was improved this probably wouldn't be
> necessary.

Hmm... this method is an API and can be called at any time by anybody, creating a new workbench window on every call.
Comment 6 Oleg Besedin CLA 2012-04-24 11:11:08 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > For some reason this method in 4.x always creates a new workbench window
> > > (unless we are closing down).
> > 
> > Basically, we want the first call to getActiveWorkbenchWindow() to return
> > something meaningful and is why we "always" instantiate a workbench window
> > instance. If our startup story was improved this probably wouldn't be
> > necessary.
> 
> Hmm... this method is an API and can be called at any time by anybody, creating
> a new workbench window on every call.

I was wrong about this, it only creates a new one if there is not one already present in the context.
Comment 7 Oleg Besedin CLA 2012-04-24 11:15:38 EDT
I restored original fix and the code around Workbench.getActiveWorkbenchWindow() as it was prior to the bug 333764 . The underlying problem in Acceleo was fixed in M6 (bug 333774).

Git reference:

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=571a10a64ba8c021d64d50a09407f9a90c2112ee
Comment 8 Oleg Besedin CLA 2012-04-24 11:16:05 EDT
*** Bug 373646 has been marked as a duplicate of this bug. ***
Comment 9 Oleg Besedin CLA 2012-04-24 11:16:20 EDT
*** Bug 365043 has been marked as a duplicate of this bug. ***
Comment 10 Oleg Besedin CLA 2012-04-24 15:16:11 EDT
I noticed that it is easy to get into a state where nobody creates WorkbenchWindow anymore. Not good, rolling back part of the fix dealing with Workbench.getActiveWorkbenchWindow().
Comment 12 Oleg Besedin CLA 2012-05-01 13:50:35 EDT
Verified in I20120430-1800.