Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Problem restoring the treeViewer state.
Problem restoring the treeViewer state. [message #459483] Fri, 01 December 2006 18:54 Go to next message
Eclipse UserFriend
Hi -

I am using a treeviewer. I provide a refresh button to the user to
update the model with the latest changes.

Before I issue a treeViewer.refresh, I hold the expanded state by

Object[] expandedElements = treeViewer.getExpandedElements();
treeViewer.refresh();
treeViewer.setExpandedElements(expandedElements);

the problem is it does not seem to restore back the expanded state which
the user has before the refresh button is hit. It always just goes back
to displaying the first level nodes of the tree.

Any ideas, what I am missing? I checked the expandedElements array set
and it seems to have the right treeItems.

eclispe 3.1 on windows xp

Thanks!

Anima.
Re: Problem restoring the treeViewer state. [message #459487 is a reply to message #459483] Sat, 02 December 2006 04:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

well in refresh I suppose you recreate all object instances, right? How
do you think TreeViewer should know which of the new objects corresponds
to the old ones? Answer it can not without *your help*.

You have 2 possibilities:
- not recreate elements already part of the old tree
- set your own comparer using StructuredViewer#setComparer()

Tom

Anima Gupta schrieb:
> Hi -
>
> I am using a treeviewer. I provide a refresh button to the user to
> update the model with the latest changes.
>
> Before I issue a treeViewer.refresh, I hold the expanded state by
>
> Object[] expandedElements = treeViewer.getExpandedElements();
> treeViewer.refresh();
> treeViewer.setExpandedElements(expandedElements);
>
> the problem is it does not seem to restore back the expanded state which
> the user has before the refresh button is hit. It always just goes back
> to displaying the first level nodes of the tree.
>
> Any ideas, what I am missing? I checked the expandedElements array set
> and it seems to have the right treeItems.
>
> eclispe 3.1 on windows xp
>
> Thanks!
>
> Anima.
>
Re: Problem restoring the treeViewer state. [message #459509 is a reply to message #459487] Sun, 03 December 2006 23:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi Tom,
Thanks Tom, I was also having same problem and your suggestion
helped me :)...

Regards,
Swapnil

Tom Schindl wrote:
> Hi,
>
> well in refresh I suppose you recreate all object instances, right? How
> do you think TreeViewer should know which of the new objects corresponds
> to the old ones? Answer it can not without *your help*.
>
> You have 2 possibilities:
> - not recreate elements already part of the old tree
> - set your own comparer using StructuredViewer#setComparer()
>
> Tom
>
> Anima Gupta schrieb:
>> Hi -
>>
>> I am using a treeviewer. I provide a refresh button to the user to
>> update the model with the latest changes.
>>
>> Before I issue a treeViewer.refresh, I hold the expanded state by
>>
>> Object[] expandedElements = treeViewer.getExpandedElements();
>> treeViewer.refresh();
>> treeViewer.setExpandedElements(expandedElements);
>>
>> the problem is it does not seem to restore back the expanded state
>> which the user has before the refresh button is hit. It always just
>> goes back to displaying the first level nodes of the tree.
>>
>> Any ideas, what I am missing? I checked the expandedElements array set
>> and it seems to have the right treeItems.
>>
>> eclispe 3.1 on windows xp
>>
>> Thanks!
>>
>> Anima.
>>
Re: Problem restoring the treeViewer state. [message #459526 is a reply to message #459487] Mon, 04 December 2006 12:49 Go to previous messageGo to next message
Eclipse UserFriend
thanks Tom - duh of me.

I will try the

> - set your own comparer using StructuredViewer#setComparer()

option.

Tom Schindl wrote:
> Hi,
>
> well in refresh I suppose you recreate all object instances, right? How
> do you think TreeViewer should know which of the new objects corresponds
> to the old ones? Answer it can not without *your help*.
>
> You have 2 possibilities:
> - not recreate elements already part of the old tree
> - set your own comparer using StructuredViewer#setComparer()
>
> Tom
>
> Anima Gupta schrieb:
>
>> Hi -
>>
>> I am using a treeviewer. I provide a refresh button to the user to
>> update the model with the latest changes.
>>
>> Before I issue a treeViewer.refresh, I hold the expanded state by
>>
>> Object[] expandedElements = treeViewer.getExpandedElements();
>> treeViewer.refresh();
>> treeViewer.setExpandedElements(expandedElements);
>>
>> the problem is it does not seem to restore back the expanded state
>> which the user has before the refresh button is hit. It always just
>> goes back to displaying the first level nodes of the tree.
>>
>> Any ideas, what I am missing? I checked the expandedElements array set
>> and it seems to have the right treeItems.
>>
>> eclispe 3.1 on windows xp
>>
>> Thanks!
>>
>> Anima.
>>
Re: Problem restoring the treeViewer state. [message #460847 is a reply to message #459483] Sat, 30 December 2006 13:00 Go to previous message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Hi,
can anyone suggest me, how to solve this problem with the IElementComparer?
I have the same problem with the expand level of my nodes after refresh,
but i did not have any idea how to use the IElementComparer for the
reseting of the expanded state.

Thanks
Florian
Previous Topic:help,problem with adding console viewer to my rcp
Next Topic:TableViewer refresh does not work
Goto Forum:
  


Current Time: Thu Mar 27 22:02:20 EDT 2025

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

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

Back to the top