Community
Participate
Working Groups
We have hit a problem where partOpened callbacks for views in the default perspective were not triggered on the first run of the application (when the welcome/intro page comes up on top of it). Our application was relying on this callback in Eclipse 3.4+ to trigger other listeners on the view, but in 4.2.1 we have had to move them into createPartControl() temporarily. I have re-produced this problem in Eclipse 4.2.1 by creating a plug-in from the "Plug-in with a view" template, adding it to the default perspective and calling the following in the createPartControl of SampleView: private void addListeners () { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); partListener = new IPartListener() { @Override public void partOpened(IWorkbenchPart part) { if (part == SampleView.this) { System.out.println("Hi, I'm " + getPartName() + " and I'm opened"); } } @Override public void partDeactivated(IWorkbenchPart part) {} @Override public void partClosed(IWorkbenchPart part) {} @Override public void partBroughtToTop(IWorkbenchPart part) {} @Override public void partActivated(IWorkbenchPart part) {} }; workbenchWindow.getPartService().addPartListener(partListener); } (Apologies if the formatting is poor) When I run this with a new workspace Eclipse starts with the welcome page and when closed my sample view is shown, but the partOpened code is not run. Re-running this without clearing the workspace the view is shown on the default perspective and the partOpened code is run.
Steven, I'll have to look at this one tomorrow...it's certainly fixable though even if the TCS (Time Constrained Solution...;-) is to force the events to fire when the Intro view closes or goes into standby mode (i.e. gets unmaximized).
Steven, I've just tried this and as far as I can determine we're firing all the partOpened avents even when the Intro is coming up...by putting a brealpoint in WorkbenchPage#firePartOpened I get the following output when opening on a 'clean' workspace... Fire: Package Explorer Fire: Outline Fire: Problems Fire: Welcome If possible could you re-test this with as recent an M-build as you can get ?
Hi Eric, I have re-tried using last nights M-build and the partOpened and partActivated get called whilst the welcome screen is open. It is a little earlier than I expected, but I'm happy with that behaviour, so it looks like this one has been fixed in 4.2.2 :D Thanks!
Steven, if you're happy so am I...except that I don't see the sysout as you describe when I copy in your listener code. I did track this down but expect that it's too deep in the code to make a quick fix for so as long as it's not affecting you I think I'll move this defect over to 4.3.
For future reference...We 'clone' the listener list(s) between the PartService (where they're registered) and WorkbenchPage (where we for some reason have duplicated the code to actually fire the listeners. The underlying reason for this is to prevent issues should a new listener get added as the result of some other listener's handling (can lead to ConcurrentModificationExceptions...). Obviously this synch'ing isn't taking place in 'real-time' nor is it copied at the instant of wanting to fire the events (a performance optimization ??).
The direct cause of the problem is that PartService is added to WorkbenchPage listeners too late - after WorkbenchPage.firePartOpened(*) is called for all views. The problem occurs only when starting eclipse with fresh workspace. After restart the initialization order is correct, even if welcome page remains open and on top.
Gerrit URL: https://git.eclipse.org/r/#/c/22931/
Wojciech, I'm not sure what your patch was supposed to do but see comment #2, I think that there's actually no defect here to fix. If I put a breakpoint in WorkbenchPage#firePartOpened we always get one on a fresh start for all the visible views...with or without your fix. Perhaps you were looking at 'partVisible' instead (since the changed code is where 'fireInitialPartVisibilityEvents' is called) ? How did you test whether or not the patch was working ? Perhaps I'm just testing the wrong things ?
I was using the code snippet from comment 0. Also: (In reply to Eric Moffatt from comment #4) > Steven, if you're happy so am I...except that I don't see the sysout as you > describe when I copy in your listener code.
Let me elaborate. The problem is that listeners added to PartService (as in the example - workbenchWindow.getPartService().addPartListener(partListener)) are not notified when eclipse opens with a fresh workspace. In 3.8 the problem does not occur. Moreover it has nothing to do with welcome page.
Wojciech, thanks...I've verified that the patch works. I can't commit it today because we've still locked out of commits in case something M6 jeopardizing comes up, I'll commit this on Monday. Sorry for the confusion on my part...
Committed Wojciech's patch, thanks dude ! http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=b20df982add55483c95e33f97d29807712ccae1c
Verified in I20140428-2000.