[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: Dynamically change icon for a treeitem on a view
|
- From: Daniel Krügler <dsp@xxxxxxx>
- Date: Wed, 09 Sep 2009 16:17:25 +0200
- Newsgroups: eclipse.platform.rcp
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.23 (Windows/20090812)
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