Bug 551634

Summary: Fragments import SharedElements too late
Product: [Eclipse Project] Platform Reporter: Rainer Herter <rainer.herter>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: joerg.specht, juergen.bohn
Version: 4.12   
Target Milestone: ---   
Hardware: All   
OS: Windows 10   
Whiteboard:
Bug Depends on:    
Bug Blocks: 562497    

Description Rainer Herter CLA 2019-09-30 10:28:37 EDT
Following project settings are given:
1) a fragment defining sharedElements for trimmedWindowImpl.
2) another fragment using imports + placeholders in perspectives. Imports + placeholders have references to the sharedElements of fragment 1.
3) just another plugin with fragment having some commands + handlers, nothing special. But this plugin is being loaded by ModelAssembler first... we don't know why.

The project is loading the plugins in a specific order to ensure that the sharedElements are being loaded BEFORE loading the other plugin requiring the sharedElements.

This project setup worked fine with Eclipse 4.7, and is broken since 4.8.
The following change in class "ModelAssembler" causes the problem.

Bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=509644

Corresponding change:
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelAssembler.java?id=b3f875c20a46971abeb23067c5cfe701d4750b23



Using fragments with sharedElements, the given order is being scrambled in the ModelAssembler --> createUnifiedFragmentList


In method "processFragments", the generated list of model fragments (variable "wrappers") has the correct order. After calling method "createUnifiedFragmentList()", the list has a faulty order. The sharedElements are at the end of the list, and thus being loaded after every other plugin. This leads to errors creating the model, because the required references for the placeholders are null.


The only fix we could find so far is to add a "sharedElements" to the plugin's fragment "3" on top of all other fragment entries, filled with a "dummy"-part without any further coding. Plugin "3" is determined as the "most important bucket" (we don't know why). The routine in the ModelAssembler then finds the "sharedElements" of plugin 3 and adds all sharedElements of all plugins to the list. Afterwards, all other fragment parts are being added. In this case, all references of all placeholders are available.

Or is there any other possibility to fix this issue?