Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamically change icon for a treeitem on a view
Dynamically change icon for a treeitem on a view [message #484788] Wed, 09 September 2009 09:53 Go to next message
Neha is currently offline NehaFriend
Messages: 52
Registered: July 2009
Member
Hi,
I need to change the icon of my tree item when it is selected.I have this
tree on a view.the icon should change back to previous when this element is
deselected.

Thanks & Regards
Neha
Re: Dynamically change icon for a treeitem on a view [message #484861 is a reply to message #484788] Wed, 09 September 2009 14:15 Go to previous messageGo to next message
Opfermann C is currently offline Opfermann CFriend
Messages: 53
Registered: July 2009
Location: Annecy
Member
Hi Neha,

I think you can use a a SelectionListener on the Tree itself to get it
work.
In the SelectionEvent, you should be able to retrieve the TreeItem
selected/deselected.
Once you have the TreeItem, change the icon as you wish.

I hope this help,

Cédric
Re: Dynamically change icon for a treeitem on a view [message #484862 is a reply to message #484788] Wed, 09 September 2009 14:17 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
Neha wrote:
> Hi,
> I need to change the icon of my tree item when it is selected.I have this
> tree on a view.the icon should change back to previous when this element is
> deselected.

Here a short idea of I would investigate:

Register as SWT.Selection listener on the tree control to
notice all selection events. Keep one reference of the very last
selection (use tree.getSelection() to the the corresponding tree
items). If on selection change an item (or object) is newly
selected, you add a special "signal" key/value (e.g. key =
"my.hot.spot.selection") to the data(String) registry
of the corresponding tree item. If an element is no longer selected,
remove the "my.hot.spot.selection" from the item. After performing
this data() update invoke viewer.update() on all changed elements.

If you use the new column-oriented label-provider, it's update
method has access to the item (via the ViewerCell parameter)
and you can check whether the signal key from it's data(String)
accessor is set or not. Now the label provider can properly chose the
right image for the item.

Depending on your use-case the corresponding data() *value* for the
special key could immediately be the special selection Image, but
that is a detail thing that might or might not help you.

HTH & Greetings from Bremen,

Daniel Krügler
Previous Topic:Problem generating product
Next Topic:How to cancel Build
Goto Forum:
  


Current Time: Sat Jan 18 21:47:09 GMT 2025

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

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

Back to the top