TreeViewer collapses when calling refresh() [message #524884] |
Sat, 03 April 2010 13: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 #524940 is a reply to message #524917] |
Sun, 04 April 2010 14:21 |
Eclipse User |
|
|
|
Originally posted by: leopold.gerlinger.aon.at
Thanks Tom for the prompt answer.
No up to now not, this seems not to be covered by the eclipse TreeViewer
article. I will try to use that and get back with an answer shortly (if
my wife let me do this ;-).
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.
Regards - Leo
Am 04.04.2010 05:38, schrieb Tom Schindl:
> Did you tried to set an IElementComparer?
>
> Tom
>
> Am 03.04.10 15:36, schrieb leoger:
>> 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 ;-)
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03677 seconds