Community
Participate
Working Groups
Created attachment 159461 [details] Active part bug tests patch Some change introduced by bug 299529's attachment 159241 [details] has caused active parts to no longer be queryable from the application's context. The attached test will reproduce the problem. I have not yet been able to create a smaller test case.
The code below will fail. If I pass in null as a scheduling strategy, it also fails pre-attachment 159241 [details]. So perhaps bug 299529 is a red herring? -------------- MApplication application = MApplicationFactory.eINSTANCE .createApplication(); MWindow window = MApplicationFactory.eINSTANCE.createWindow(); application.getChildren().add(window); application.setSelectedElement(window); MPart partA = MApplicationFactory.eINSTANCE.createPart(); MPart partB = MApplicationFactory.eINSTANCE.createPart(); window.getChildren().add(partA); window.getChildren().add(partB); window.setSelectedElement(partA); IEclipseContext applicationContext = E4Application .createDefaultContext(); applicationContext.set(MApplication.class.getName(), application); application.setContext(applicationContext); Workbench.processHierarchy(application); IEclipseContext windowContext = EclipseContextFactory.create( applicationContext, null); window.setContext(windowContext); windowContext.set(MWindow.class.getName(), window); IEclipseContext partContextA = EclipseContextFactory.create( windowContext, null); partA.setContext(partContextA); partContextA.set(MPart.class.getName(), partA); IEclipseContext partContextB = EclipseContextFactory.create( windowContext, null); partB.setContext(partContextB); partContextB.set(MPart.class.getName(), partB); applicationContext.set(IContextConstants.ACTIVE_CHILD, windowContext); windowContext.set(IContextConstants.ACTIVE_CHILD, partContextA); window.getContext().set(IContextConstants.ACTIVE_CHILD, partB.getContext()); Object o = applicationContext.get(IServiceConstants.ACTIVE_PART); assertEquals(partB, o); window.getContext().set(IContextConstants.ACTIVE_CHILD, partA.getContext()); o = applicationContext.get(IServiceConstants.ACTIVE_PART); assertEquals(partA, o);
To be honest, the tests may not actually test the incorrect behaviour in question. The best way is to just start up the e4 IDE application and try to save. Ctrl+S does nothing because the system cannot find an active part. Just alter the canExecute(MPart)'s parameter to be @Optional and you will see that it is getting nulls.
Created attachment 159482 [details] Patch This is caused by the wrong code in the ActivePartLookupFunction. The ActivePartLookupFunction depends on MWindow/MApplication.getContext() result: IEclipseContext current = window.getContext(); That is the value stored outside of the context. It is not set originally so there is not dependency on IContextConstants.ACTIVE_CHILD created. When it is set later, the context is not notified as no dependecy were created. I'll fix the ordering so that context is set on MApplication before the class is added to the context. The patch also fixes a problem in the context eventing that was exposed by the change.
Patch applied to CVS Head. I'll add comment to the bug 295003 on the ActivePartLookupFunction.