Bug 475841 - EModelService findElements() does not allow restricting search to viewable elements
Summary: EModelService findElements() does not allow restricting search to viewable el...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Brian de Alwis CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-25 12:50 EDT by Brian de Alwis CLA
Modified: 2015-08-26 15:45 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 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.