Operation on Collapsed Tree Item [message #855990] |
Wed, 25 April 2012 05:14  |
Eclipse User |
|
|
|
Hi All,
I have created tree using TreeViewer. If I am trying to do any operation on collapsed tree items, it does not have any effect.
For example, if I want to set an image to a child item and I try to traverse the tree to find the same, below code returns empty array when tree items are collapsed.
TreeItem[] items = treeItem.getItems();
Can any one help on this?
|
|
|
Re: Operation on Collapsed Tree Item [message #856019 is a reply to message #855990] |
Wed, 25 April 2012 05:43   |
Eclipse User |
|
|
|
Snehil,
You should generally be working with content and label providers, not
directly with tree items. In the later case your question is an SWT
question, not a JFace question. JFace manages the underlying widgets
for you via the providers so you should only operate on the model level
and content/label provider level. I.e., you'd tell the viewer that some
object's label is changed and ensure that the label provider returns the
appropriate new image when asked for the image.
On 25/04/2012 11:14 AM, Snehil Shrivastava wrote:
> Hi All,
>
> I have created tree using TreeViewer. If I am trying to do any
> operation on collapsed tree items, it does not have any effect.
>
> For example, if I want to set an image to a child item and I try to
> traverse the tree to find the same, below code returns empty array
> when tree items are collapsed.
>
> TreeItem[] items = treeItem.getItems();
>
> Can any one help on this?
>
>
|
|
|
|
|
Re: Operation on Collapsed Tree Item [message #865088 is a reply to message #856021] |
Mon, 30 April 2012 04:12  |
Eclipse User |
|
|
|
Items are created in a lazy manner so there are no child items until you
expanded the TreeItem at least once.
But lig you and Ed stated already do not work with the low-level SWT-API
if you are using Viewers.
Tom
Am 25.04.12 11:46, schrieb Thorsten Schlathölter:
> Hi,
> TreeItems are widgets. If the tree is collapsed, there are no widgets
> for the hidden nodes. In other words there is only an item per visible
> row. If a row is collapsed child items are pruned and disposed. You
> should set the image via the LabelProvider. I would say if you need to
> traverse the tree, traverse your model, not the (UI)Tree.
>
> Regards,
> Thorsten
|
|
|
Powered by
FUDForum. Page generated in 0.35495 seconds