| [news.eclipse.platform] Re: how to use treeViewer getExpandedElements method |
Conor,
org.eclipse.ui.views.navigator.ResourceNavigator.restoreState uses it.
Hi,
I am using some of the EMF generated Editor code of my Model to display a TreeViewer in a View. I have a filter on the TreeViewer that filters the tree based on whatever the user selects in a dropdown. When a user makes a particular selection in the dropdown, it may result in an element being filtered out of the viewer, and what I want to do is keep track of the expansion state of these elements that are filtered out so that I can restore the expansion state when it gets filtered back into the view.
I have seen the Treeviewer getExpandedElements and setExpandedElements methods in the TreeViewer API doc which I think will do the job, however I could find any examples of their usage. I tried using them within the select method of the ViewerFilter class, so that if an element was being filtered out the viewer would retain a reference to the expanded elements and then restore the expansion state when the elements were filtered back in, but this did not work. Does anyone know any examples of the correct usage of these methods or point out where they should be used?
Many thanks, Conor