Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Saving and restoring a TreeViewer's expanded state
Saving and restoring a TreeViewer's expanded state [message #333581] Wed, 17 December 2008 21:23
Tomas Pollak is currently offline Tomas PollakFriend
Messages: 4
Registered: July 2009
Junior Member
Hello, I have the following problem:

I have a view with a TreeViewer that shows some info for an object which
in the business model is called a "session". When the user switches
sessions, I need to redraw the tree, and if the user switches back I need
to show the tree as it was previous to the switch.

In order to solve that, I am using the getExpandedElements() and
setExpandedElements() methods from the TreeViewer, to store the expanded
elements in an array in my model "session" object.

I reasoned that the most natural place to do this is in the inputChanged()
method of the ContentProvider. However when I tried it it had no effect.
Apparently the inputChanged() method is called _before_ actually changing
the input for the viewer. As a workaround I moved this logic to the View
itself, where I can call these methods after the inputChanged() is
completed.

Do you have any idea why this is implemented like this?
Is there a "best practice" for doing this that I'm not aware of?

I would like this responsibility to be in the content provider, because
that would also mean it's easier to test (than if it were in the view).

Thank you.
Tomás
Previous Topic:Re: Retrieve feature info
Next Topic:How to create an indirect reference to the javadoc for a classpath entry
Goto Forum:
  


Current Time: Thu Dec 26 17:56:52 GMT 2024

Powered by FUDForum. Page generated in 0.03015 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top