TreeViewer collapses when calling refresh() [message #524884] |
Sat, 03 April 2010 09:36  |
Eclipse User |
|
|
|
Originally posted by: leopold.gerlinger.aon.at
Hello everybody!
I'm working on an explorer-like window to allow my customer to edit
database items from our SWT client. The window has a TreeViewer on the
left and a editor window to the right. Everything works fine, except
when I call refresh() on the TreeViewer to update the visible items
(text and image depends on a status cache). In this case most of my
tree collapses and is not opened again.
This seems to be bound to the fact that I load the child items of the
tree from the database everytime the getChildren() method is called.
It seems like the TreeViewer compares the object id's and collapses if
it's not able to match it with the ones returned by the new
getChildren() call. I've also tried to implement the equals() method of
my root item class to compare against the primary key of the database
but this doesn't help (or I've done something wrong).
In an older implementation (having the whole DB tables cached) it worked
when I copied the items attributes (the ones from the recently fetched
from the DB) to the items already known by the TreeViewer to avoid
returning new item objects to the TreeViewer. So there either seems a
dependency on the object id's or the hashcode of the objects.
Any hints of how I could solve the problem?
Regards - Leo
P.S.: I know, a snippet would be fine, but then I'd have to deliver my
DB too - that's a bit too much ;-)
|
|
|
|
|
Re: TreeViewer collapses when calling refresh() [message #525345 is a reply to message #524940] |
Tue, 06 April 2010 05:50  |
Eclipse User |
|
|
|
On 04.04.2010 16:21, leoger wrote:
> Anyway will I run into problems when producing the same hashcode for
> different elements then? I would implement to give the hashcode of the
> DB primary key as a result to hashcode(), so there will be the same
> has for two POJO's from the DB.
Equal hash values are uncritical for the functionality, because hash
collisions "only" influence the performance (which of-course may make
the hash-map unusable for a badly-chosen hash function). I assume that
your question actually refers to: May there be equal elements in the
viewer according to the IElementComparer query? The answer is: No,
because there exists the implied assumption that every element is
unique.
HTH & Greeetings from Bremen,
Daniel Krügler
|
|
|
Powered by
FUDForum. Page generated in 0.04002 seconds