Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Snehil Shrivastava is currently offline Snehil Shrivastava
Messages: 17
Registered: April 2012
Junior Member
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
Ed Merks is currently offline Ed Merks
Messages: 26011
Registered: July 2009
Senior Member
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
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 208
Registered: February 2012
Location: Düsseldorf
Senior Member
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
Snehil Shrivastava is currently offline Snehil Shrivastava
Messages: 17
Registered: April 2012
Junior Member
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
Thomas Schindl is currently offline Thomas Schindl
Messages: 5292
Registered: July 2009
Senior Member
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:ComboViewer with a value not on the list
Next Topic:Model to Treeviewer databinding problem
Goto Forum:
  


Current Time: Thu Aug 28 03:20:51 EDT 2014

Powered by FUDForum. Page generated in 0.08290 seconds