Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » tree.indexOf() always returning -1
tree.indexOf() always returning -1 [message #455194] Tue, 10 May 2005 04:52 Go to next message
Eclipse UserFriend
Originally posted by: CupertinoIndian.yahoo.com

I created a tree structure with depth 4 or 5. I am trying to find the
index of the item selected and I am always getting -1. Any ideas?

TreeItem[] treeItem = tree.getSelection();
if(treeItem != null && treeItem.length >= 0)
{
int index = tree.indexOf(treeItem[0]);
// index is always -1 ???
}
Re: tree.indexOf() always returning -1 [message #455248 is a reply to message #455194] Tue, 10 May 2005 13:04 Go to previous messageGo to next message
Eclipse UserFriend
Tree.indexOf() only returns the index of the direct children of a node. Is
that what you are seeing?

"Cupertino Indian" <CupertinoIndian@yahoo.com> wrote in message
news:d5pt64$f9b$1@news.eclipse.org...
>
> I created a tree structure with depth 4 or 5. I am trying to find the
> index of the item selected and I am always getting -1. Any ideas?
>
> TreeItem[] treeItem = tree.getSelection();
> if(treeItem != null && treeItem.length >= 0)
> {
> int index = tree.indexOf(treeItem[0]);
> // index is always -1 ???
> }
Re: tree.indexOf() always returning -1 [message #455255 is a reply to message #455248] Wed, 11 May 2005 01:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: CupertinoIndian.yahoo.com

Ooh, I see. Thanks for information. I guess I need to iterate through
the whole tree to find the real location...unless somebody has better idea.


Steve Northover wrote:
> Tree.indexOf() only returns the index of the direct children of a node. Is
> that what you are seeing?
>
> "Cupertino Indian" <CupertinoIndian@yahoo.com> wrote in message
> news:d5pt64$f9b$1@news.eclipse.org...
>
>>I created a tree structure with depth 4 or 5. I am trying to find the
>>index of the item selected and I am always getting -1. Any ideas?
>>
>>TreeItem[] treeItem = tree.getSelection();
>>if(treeItem != null && treeItem.length >= 0)
>>{
>>int index = tree.indexOf(treeItem[0]);
>>// index is always -1 ???
>>}
>
>
>
Re: tree.indexOf() always returning -1 [message #459089 is a reply to message #455255] Mon, 01 August 2005 13:25 Go to previous message
Eclipse UserFriend
Cupertino Indian wrote:
>
> Ooh, I see. Thanks for information. I guess I need to iterate through
> the whole tree to find the real location...unless somebody has better idea.

??? don't traverse the tree, but work back up to the root.

Get the selected item's parent item with getParentItem(), and if it
isn't null, get your item's index within its parent and then do it
all over again for the parent item until you reach the root

> Steve Northover wrote:
>
>> Tree.indexOf() only returns the index of the direct children of a
>> node. Is
>> that what you are seeing?
>>
>> "Cupertino Indian" <CupertinoIndian@yahoo.com> wrote in message
>> news:d5pt64$f9b$1@news.eclipse.org...
>>
>>> I created a tree structure with depth 4 or 5. I am trying to find the
>>> index of the item selected and I am always getting -1. Any ideas?
>>>
>>> TreeItem[] treeItem = tree.getSelection();
>>> if(treeItem != null && treeItem.length >= 0)
>>> {
>>> int index = tree.indexOf(treeItem[0]);
>>> // index is always -1 ???
>>> }
Previous Topic:extend NavigatorView transfer type (DND issue)
Next Topic:Hourglass!
Goto Forum:
  


Current Time: Wed Jul 23 22:52:21 EDT 2025

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

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

Back to the top