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

Bug 314761

Summary: components.e4xmi should be processed in bundle-dependency order
Product: [Eclipse Project] e4 Reporter: Brian de Alwis <bsd>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, ob1.eclipse, pwebster, tom.schindl
Version: unspecified   
Target Milestone: 1.0 RC0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch to ModelExtensionProcessor.java none

Description Brian de Alwis CLA 2010-05-27 15:35:06 EDT
BuildId: HEAD 

components.e4xmi files contributed through the org.eclipse.e4.workbench.model extension point are processed in no defined order.  As a result, a components.e4xmi cannot reliably depend on elements defined in another components.e4xmi file.

The following patch (to follow) ensures that the extensions are topologically sorted by their contributor's dependencies.  With this patch, components.e4xmi can depend on other components.e4xmi files -- providing their containing plugins have a direct dependency.

This will likely be a necessary piece to help with bug 309867.
Comment 1 Brian de Alwis CLA 2010-05-27 15:35:43 EDT
Created attachment 170253 [details]
patch to ModelExtensionProcessor.java

Cause the ModelExtensionProcessor to process extensions in dependency
order.  This ensures that components.e4xmi can rely on elements
defined in other components.e4xmi (providing their plugins express
the appropriate dependency, of course).
Comment 2 Paul Webster CLA 2010-05-28 07:40:47 EDT
Interesting approach.

In menu contributions we dealt with this by providing a processing loop that continues to process contributions until the only ones left cannot have their target location met (a combination of parent ID and before/after sibling ID)

PW
Comment 3 Oleg Besedin CLA 2010-05-28 16:54:33 EDT
Wow, Brian, thank you!

Very nice addition. We might need to add cycles to the processing as Paul suggested in the comment 2, but this change improves current behavior a lot.
Comment 4 Thomas Schindl CLA 2010-05-31 11:15:00 EDT
This leads to an exception when launching the the Contacts-Demo:
-----8<-----
!ENTRY org.eclipse.e4.ui.workbench 4 0 2010-05-31 17:13:01.219
!MESSAGE 
!STACK 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.eclipse.e4.workbench.ui.internal.ModelExtensionProcessor.topoSort(ModelExtensionProcessor.java:268)
	at org.eclipse.e4.workbench.ui.internal.ModelExtensionProcessor.addModelExtensions(ModelExtensionProcessor.java:97)
	at org.eclipse.e4.workbench.ui.internal.ResourceHandler.loadMostRecentModel(ResourceHandler.java:195)
-----8<-----
Comment 5 Thomas Schindl CLA 2010-05-31 11:21:50 EDT
... which leads to shutdown problems because the reconciler is not created
Comment 6 Brian de Alwis CLA 2010-05-31 12:18:50 EDT
Oops.  Thanks for finding that, Tom.  Fix committed to CVS.