Skip to main content


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 09:14 Go to next message
Snehil Shrivastava is currently offline Snehil ShrivastavaFriend
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 09:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
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?
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Operation on Collapsed Tree Item [message #856021 is a reply to message #855990] Wed, 25 April 2012 09:46 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
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 10:56 Go to previous messageGo to next message
Snehil Shrivastava is currently offline Snehil ShrivastavaFriend
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 08:12 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
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:Eclipse software update: NPE popup on saving edited source
Next Topic:ComboViewer with a value not on the list
Goto Forum:
  


Current Time: Tue Mar 19 07:34:39 GMT 2024

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

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

Back to the top