Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer refresh
TreeViewer refresh [message #547302] Fri, 16 July 2010 09:08 Go to next message
Philipp Schill is currently offline Philipp SchillFriend
Messages: 11
Registered: July 2010
Junior Member
Hello all,
i have a problem with a treeviewer.
My problem is, when I call treeviewer.refresh() my tree collapses until the first level, e.g.

original state before rerfesh:

Customer
--- Project A
------ Folder AA
--------- File AA
--------- File AB
--- Project B
------Folder BA
--------- File BA
--------- File BB

after calling refresh, my tree looks like:

Customer
--- Project A
--- Project B

(collapsed to the first level).

Does anyone have any hints what to do to fix this problem?

Environment:
Eclipse Build id: 20100218-1602
WinXP

Thanks and regards!
Re: TreeViewer refresh [message #547450 is a reply to message #547302] Fri, 16 July 2010 21:27 Go to previous messageGo to next message
budili Missing name is currently offline budili Missing nameFriend
Messages: 64
Registered: May 2010
Member
If you want to expand all items, after refresh the viewer,
then use the simpel method expand:
treeViewer.expandAll();
Re: TreeViewer refresh [message #547534 is a reply to message #547302] Sun, 18 July 2010 14:03 Go to previous messageGo to next message
Philipp Schill is currently offline Philipp SchillFriend
Messages: 11
Registered: July 2010
Junior Member
No, I only want to get my tree like before the refresh.

So my question is still, what do I have to do, or wahts wrong with my implementation, when my tree collapses to the first level?

Thanks!
Re: TreeViewer refresh [message #547539 is a reply to message #547534] Sun, 18 July 2010 15:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Implement an IElementComparer
Am 18.07.10 16:03, schrieb Philipp Schill:
> No, I only want to get my tree like before the refresh.
>
> So my question is still, what do I have to do, or wahts wrong with my
> implementation, when my tree collapses to the first level?
>
> Thanks!
Re: TreeViewer refresh [message #548098 is a reply to message #547539] Tue, 20 July 2010 16:15 Go to previous messageGo to next message
Mark Storer is currently offline Mark StorerFriend
Messages: 46
Registered: May 2010
Location: Vista, CA
Member

Tom Schindl wrote on Sun, 18 July 2010 08:15
Implement an IElementComparer



So what do equals and hashCode have to do with the tree being open or closed?

A guess: Refresh recreates the tree such that it is "equal". If the new equal/hash function that includes the nodes "open-ness" will force refesh() to preserve the tree's state.

(and presumably the root node is a special case that already handles this... which makes me wonder why the default tree node doesn't as well.)



--Mark Storer
Senior Software Engineer
Autonomy Cardiff

import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;

Google Code Search

[Updated on: Tue, 20 July 2010 16:21]

Report message to a moderator

Re: TreeViewer refresh [message #548105 is a reply to message #548098] Tue, 20 July 2010 16:28 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Most of the time when people do a refresh they recreat the underlying
model data.

For a TreeViewer a refresh means to completely recreate itself
(=Disposing/recreating TreeItems - there's some optimization code to not
dispose all but it's easier to understand this way) which means they all
loose their state but before doing so it remembers the open TreePaths
(Domain-Object-List) and tries to restore the state after the refresh.

The problem is that if you have created new object instances how should
the viewer know which object corresponds to each other.

There are now 2 solutions:
a) Overload equals/hashCode in your domain code
b) Set an IElementComparer to assist the Viewer code to find logically
equal objects

Tom

Am 20.07.10 18:15, schrieb Mark Storer:
> Tom Schindl wrote on Sun, 18 July 2010 08:15
>> Implement an IElementComparer
>
>
> So what do equals and hashCode have to do with the tree being open or
> closed?
>
> A guess: Refresh recreates the tree such that it is "equal". If the
> new equal/hash state includes the nodes "open-ness" then the tree will
> be preserved when its refreshed.
>
>
>
Previous Topic:TreeViewer refresh
Next Topic:Sorting a TableViewer: the simplest case
Goto Forum:
  


Current Time: Sat Apr 20 03:18:22 GMT 2024

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

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

Back to the top