Bug 475841

Summary: EModelService findElements() does not allow restricting search to viewable elements
Product: [Eclipse Project] Platform Reporter: Brian de Alwis <bsd>
Component: UIAssignee: Brian de Alwis <bsd>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: tom.schindl
Version: 4.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Brian de Alwis CLA 2015-08-25 12:50:52 EDT
In trying to fix bug 471030, where I'm trying to determine the MParts that are actually visible within the current perspective, I'm hitting a situation where I want to obtain the list of currently *viewable* parts.  Fixing bug 455281 to make IN_ACTIVE_PERSPECTIVE and IN_ANY_PERSPECTIVE is insufficient as I need to be actually check and handle placeholders. 

This problem is seen elsewhere, such as in WorkbenchPage#getViewReferences() and PartServiceImpl#isPartVisible(): these methods repeated calls to EModelService#findElements() for MUIElements, MPlaceholders, and MParts, to check if an element is hosted within a MPlaceholder and verify that it is visible and rendered.  This information can be obtained during the initial traversal of the tree.  More importantly, the traversal is *required* as a part could be visible but not shown as one of its ancestors is hidden.

My proposal is to pass an additional Selector instance to control traversal.  I don't think we can overload the existing matcher to do both selecting and traversing.

An alternative might be to add a new flag IS_VIEWABLE to EModelService#findElements() that would check elements along the traversal.  I hesitate about this as it pushes knowledge of visibility and renderedness into the model service.
Comment 1 Thomas Schindl CLA 2015-08-25 12:55:18 EDT
Now that we have java8 couldn't we have a stream api
Comment 2 Brian de Alwis CLA 2015-08-25 15:41:43 EDT
Tom, could you explain more about what you're thinking?  Do you mean as a return value instead of a List?  Otherwise my understanding is that creating our own Stream implementations was frowned upon.