|
|
Re: Dynamically change icon for a treeitem on a view [message #484862 is a reply to message #484788] |
Wed, 09 September 2009 14:17 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03874 seconds