Skip to main content



      Home
Home » Eclipse Projects » JFace » Operation on Collapsed Tree Item
Operation on Collapsed Tree Item [message #855990] Wed, 25 April 2012 05:14 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #856021 is a reply to message #855990] Wed, 25 April 2012 05:46 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Operation on Collapsed Tree Item [message #856081 is a reply to message #856021] Wed, 25 April 2012 06:56 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Ed Merks and Thorsten Schlathölter
I have to work with model objects.
Re: Operation on Collapsed Tree Item [message #865088 is a reply to message #856021] Mon, 30 April 2012 04:12 Go to previous message
Eclipse UserFriend
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
Previous Topic:Eclipse software update: NPE popup on saving edited source
Next Topic:ComboViewer with a value not on the list
Goto Forum:
  


Current Time: Tue Jul 22 19:03:54 EDT 2025

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

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

Back to the top