Bug 571372 - WorkbenchPage#getActivePart() returns null for next instance of E4 part
Summary: WorkbenchPage#getActivePart() returns null for next instance of E4 part
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.19   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-19 14:16 EST by Wim Jongman CLA
Modified: 2021-02-21 08:15 EST (History)
1 user (show)

See Also:


Attachments
Test project that shows the issue (75.67 KB, application/x-zip-compressed)
2021-02-19 14:16 EST, Wim Jongman CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wim Jongman CLA 2021-02-19 14:16:35 EST
Created attachment 285613 [details]
Test project that shows the issue

When an E4 part in a mixed environment is instantiated multiple times (e.g. as an editor), null is returned for getActivePart on any other instance but the first.

The E4PartWrapper logic is not initiated for multiple occurrences of the same part.

Attached is a project where two instances of the same part are set up next to an E3 part. Each part contains a button that calls getActivePart and shows the result.
Comment 1 Rolf Theunissen CLA 2021-02-21 08:08:25 EST
The root cause is that there is no secondary identifier set for parts created with the EModelService. That is, the MParts get all the same element identifier, it is not possible to distinguishes multiple instances of the descriptor.

In the workbench, parts must have unique identifiers, otherwise view-references will not be created correctly: In WorkBench#createViewReference and WorkbenchPage#addViewReference, only the element identifier of the part is used. Therefore, there is no view reference created for the second instance of the E4part. Then in WorkbenchPage#getWorkbenchPart, there is no view reference for the second E4part. Although there was an active MPart, the corresponding IWorkbenchPart could not be found (it was never created).
Comment 2 Eclipse Genie CLA 2021-02-21 08:15:06 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/176576