Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Keeping top displayed node the same during tree refreshing
Keeping top displayed node the same during tree refreshing [message #778264] Thu, 12 January 2012 03:03 Go to next message
John Lussmyer is currently offline John LussmyerFriend
Messages: 96
Registered: December 2010
Member
I have a Tree view with lots of nodes.
Sometimes a notification comes in of a change to the root node.
Since the new node is a new object, I can't just updated it. I have to do a setInput() and replace the tree.
I'd LIKE to be able to rescroll the tree so the same "value" is still at the top of the view.
So far I haven't found any way to do that.
I can use TreeViewer.getTree().getTopItem() to get the top item before the setInput().
I then get the data item value so I know what needs to be the new top value.
I just haven't found any way to use setTopItem() to restore the state, since all the TreeItems will be new now.
There doesn't seem to be a way to find the new TreeItem that has the correct data value, so I can set it to be the top item.

Any suggestions?
Re: Keeping top displayed node the same during tree refreshing [message #778448 is a reply to message #778264] Thu, 12 January 2012 07:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Am 12.01.12 04:03, schrieb Missing name Mising name:
> I have a Tree view with lots of nodes.
> Sometimes a notification comes in of a change to the root node. Since
> the new node is a new object, I can't just updated it. I have to do a
> setInput() and replace the tree.

You can call add!

> I'd LIKE to be able to rescroll the tree so the same "value" is still at
> the top of the view.
> So far I haven't found any way to do that.
> I can use TreeViewer.getTree().getTopItem() to get the top item before
> the setInput().
> I then get the data item value so I know what needs to be the new top
> value.
> I just haven't found any way to use setTopItem() to restore the state,
> since all the TreeItems will be new now.

You can remember the domain object instead using TreeItem.getData, after
the refresh you search for the item (problem is that nested items are
created lazily!)

Bottomline: I think you should use the add/remove API.

Tom

> There doesn't seem to be a way to find the new TreeItem that has the
> correct data value, so I can set it to be the top item.
>
> Any suggestions?
>
Re: Keeping top displayed node the same during tree refreshing [message #778491 is a reply to message #778448] Thu, 12 January 2012 20:54 Go to previous message
John Lussmyer is currently offline John LussmyerFriend
Messages: 96
Registered: December 2010
Member
Add doesn't seem relevant.
This isn't a new node that's being added to the tree.
I need to REPLACE the existing node.
And sometimes the node being replaced is the root node.

Even if I'm not replacing the root node, but 1 level down, I have to refresh the root, which looses the current view position.
Previous Topic:Fix "Missing name Missing name" in forums
Next Topic:Load Image
Goto Forum:
  


Current Time: Wed Dec 17 20:02:48 GMT 2014

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

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