Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer: Updating the icon on expand/collapse
TreeViewer: Updating the icon on expand/collapse [message #512451] Fri, 05 February 2010 08:27 Go to next message
Eclipse UserFriend
Originally posted by: Raajesh.Kashyap.ext.ugs.com

I have a TreeViewer, whose label provider supplies a folder icon for the
folder nodes being displayed in the tree.

We have a requirement that when the folder node is expanded, the icon
against it must change to an expanded folder icon. I could not find how
I can make the label provider do this. There is no hook I could find to
trigger the label provider to provide an updated icon. I do not want to
refresh the node - just need the icon to be updated on expand.

Is there any way to accomplish this?

I am using Eclipse 3.5, but may need this for 3.2 and 3.3 (on which our
product is supported as well).
Re: TreeViewer: Updating the icon on expand/collapse [message #512466 is a reply to message #512451] Fri, 05 February 2010 09:03 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Use a ColumnLabelProvider (or CellLabelProvider) overwrite
update(ViewerCell) and check there if the item is expanded, attach an
expand/collapse listener on the Tree and call
Viewer#update(item.getData()) in the listener.

Tom

Am 05.02.10 09:27, schrieb Raajesh B.Kashyap:
> I have a TreeViewer, whose label provider supplies a folder icon for the
> folder nodes being displayed in the tree.
>
> We have a requirement that when the folder node is expanded, the icon
> against it must change to an expanded folder icon. I could not find how
> I can make the label provider do this. There is no hook I could find to
> trigger the label provider to provide an updated icon. I do not want to
> refresh the node - just need the icon to be updated on expand.
>
> Is there any way to accomplish this?
>
> I am using Eclipse 3.5, but may need this for 3.2 and 3.3 (on which our
> product is supported as well).
Re: TreeViewer: Updating the icon on expand/collapse [message #512467 is a reply to message #512466] Fri, 05 February 2010 09:05 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Ups this doesn't work on 3.2 there you need to restore this expansion
state in your domain model because the labelprovider has no idea of the
item it is just updating.

Tom

Am 05.02.10 10:03, schrieb Tom Schindl:
> Use a ColumnLabelProvider (or CellLabelProvider) overwrite
> update(ViewerCell) and check there if the item is expanded, attach an
> expand/collapse listener on the Tree and call
> Viewer#update(item.getData()) in the listener.
>
> Tom
>
> Am 05.02.10 09:27, schrieb Raajesh B.Kashyap:
>> I have a TreeViewer, whose label provider supplies a folder icon for the
>> folder nodes being displayed in the tree.
>>
>> We have a requirement that when the folder node is expanded, the icon
>> against it must change to an expanded folder icon. I could not find how
>> I can make the label provider do this. There is no hook I could find to
>> trigger the label provider to provide an updated icon. I do not want to
>> refresh the node - just need the icon to be updated on expand.
>>
>> Is there any way to accomplish this?
>>
>> I am using Eclipse 3.5, but may need this for 3.2 and 3.3 (on which our
>> product is supported as well).
>
Previous Topic:How to correctly write a custom widget based on existing widgets
Next Topic:[DataBinding] When to call dispose on context ?
Goto Forum:
  


Current Time: Fri Mar 29 08:08:56 GMT 2024

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

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

Back to the top