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 03:27 Go to next message
Eclipse User
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 04:03 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5228
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 04:05 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5228
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:RuleBasedPartitionScanner problem.
Next Topic:[DataBinding] When to call dispose on context ?
Goto Forum:
  


Current Time: Wed Jul 23 08:11:13 EDT 2014

Powered by FUDForum. Page generated in 0.04744 seconds