Community
Participate
Working Groups
Currently in the Eclipse JFace Tree Viewer infrastructure we have a method called getVisibleExpandedElements that returns all the visible "and" expanded object in the view. What I wanted was a method that returned all the visible objects (whether expanded or not) I am not sure if the intention of the getVisibleExpandedElements method was getting all visible elements or not but I think this is a much more important behaviour from the UI point-of-view.. For example in my case I have 2 label providers for my tree view and I need to switch between them from time to time and to do the switch in a more optimized manner I need to get the visible objects and call update on them instead of calling refresh on the entire view which is very expensive execution wise. I had implemented the method and am pasting it below: public Object[] getVisibleElements(){ ArrayList visibleElements = new ArrayList(); recursiveGetVisibleElements(visibleElements,getTree()); return visibleElements.toArray(); } /** * @param tree * @return */ private void recursiveGetVisibleElements(ArrayList visibleElements, Widget item) { if (!(item instanceof Item) || getExpanded((Item)item)) { Item[] children = getChildren(item); for (int i = 0; i < children.length; i++) { Item child = children[i]; Object data = child.getData(); if (data != null) visibleElements.add(data); recursiveGetVisibleElements(visibleElements, child); } } } Its very similar to the getVisibleExpandedElements method, the difference being here I am checking if the passed object is expanded and if its I add its children to the resulting list and then recurse on the children whereas in the getVisibleExpandedElements method first the children of the passed element are obtained and then the children are checked to see whether they are expended and if they are then they are added to the resulting list and the method is recursed on them. Thanks!
*** Bug 59141 has been marked as a duplicate of this bug. ***
Not for 3.0
Reopening now that 3.0 has shipped
*** This bug has been marked as a duplicate of 2713 ***