Bug 562916 - Offer a method in EModelService to get the parent of a part / placeholder
Summary: Offer a method in EModelService to get the parent of a part / placeholder
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.16   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: 2020-05-07 04:58 EDT by Lars Vogel CLA
Modified: 2021-03-19 08:56 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2020-05-07 04:58:05 EDT
See https://git.eclipse.org/r/#/c/162592/4/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java

We frequently (also in client code) need to access the parent of a part. As any part can be a placeholder, we frequently have to use the pattern of checking if the part.getCurSharedRef() != null and if not null access the parent of the placeholder and if not present access the parent of the part.

I suggest we add a method to the model service:

MUIElement getParentForPart(MPart part)
Comment 1 Eclipse Genie CLA 2020-05-07 05:02:10 EDT
New Gerrit change created: https://git.eclipse.org/r/162623
Comment 2 Rolf Theunissen CLA 2021-03-19 08:56:41 EDT
Shared elements are at least MPart, MArea, MPartSashContainer, MPartStack (those are shown in the model spy). For all these elements a similar method would be beneficial.

Not sure how to name the method though. The parent of a MPlaceholder can and will change. It should be clear that the parent is not the same as the container of an element.

suggestions:

MUIElement getCurrentParent(MUIElement element)
MUIElement getEffectiveParent(MUIElement element)

MUIElement getGuardian(MUIElement element) 
Guardian captures best the nature of what this method does, that is determine which element currently has custody of the element. However, not many people will guess that this method would be around if it has that name.