Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » [MacOS X.3.6] TableTree getting selected item
[MacOS X.3.6] TableTree getting selected item [message #446386] Wed, 24 November 2004 10:07 Go to next message
Eclipse UserFriend
Originally posted by: yvon_thoraval.mac.com

Hy all,

i've added a SelectionListener to my TableTree however, the indexOf
selected item returns -1 if not at index 0 and the associated text to null.

is that a known, OS dependant, bug ?

Yvon

Here is my code :

<code>
SelectionListener tableTreeListener = new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
System.out.println("widgetSelected : " + e.widget);
TableTree tt = (TableTree) e.widget;
TableTreeItem[] ttis = tt.getSelection();
int ttin = tt.getSelectionCount();
System.out.println("tti number : " + ttin);
System.out.println("tti index : " +
tableTree.indexOf(ttis[0]));
System.out.println("tti texte : " + ttis[0].getText());
}
public void widgetDefaultSelected(SelectionEvent arg0) { }
};
tableTree.addSelectionListener(tableTreeListener);
</code>
Notice that only one is selected at this time, reason for ttis[0]...
Re: [MacOS X.3.6] TableTree getting selected item [message #446417 is a reply to message #446386] Wed, 24 November 2004 18:13 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You need to call indexOf on the parent of the TableTreeItem. Sometimes this
is the TableTree - when the item is a root node - and sometimes the parent
is a TableTreeItem. The same applies for Tree and TreeItems.

See changes to your code below:


SelectionListener tableTreeListener = new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
System.out.println("widgetSelected : " + e.widget);
TableTree tt = (TableTree) e.widget;
TableTreeItem[] ttis = tt.getSelection();
int ttin = tt.getSelectionCount();
System.out.println("tti number : " + ttin);
//System.out.println("tti index : " +
tableTree.indexOf(ttis[0]));
TableTreeItem parentItem = ttis[0].getParentItem();
if (parentItem != null) {
System.out.println("tti index : " +
parentItem.indexOf(ttis[0]));
} else {
System.out.println("tti index : " +
tableTree.indexOf(ttis[0]));
}
System.out.println("tti texte : " + ttis[0].getText());
}
public void widgetDefaultSelected(SelectionEvent arg0) { }
};

"Yvon Thoraval" <yvon_thoraval@mac.com> wrote in message
news:co1mhu$1tu$1@www.eclipse.org...
> Hy all,
>
> i've added a SelectionListener to my TableTree however, the indexOf
> selected item returns -1 if not at index 0 and the associated text to
> null.
>
> is that a known, OS dependant, bug ?
>
> Yvon
>
> Here is my code :
>
> <code>
> SelectionListener tableTreeListener = new SelectionListener() {
> public void widgetSelected(SelectionEvent e) {
> System.out.println("widgetSelected : " + e.widget);
> TableTree tt = (TableTree) e.widget;
> TableTreeItem[] ttis = tt.getSelection();
> int ttin = tt.getSelectionCount();
> System.out.println("tti number : " + ttin);
> System.out.println("tti index : " +
> tableTree.indexOf(ttis[0]));
> System.out.println("tti texte : " + ttis[0].getText());
> }
> public void widgetDefaultSelected(SelectionEvent arg0) { }
> };
> tableTree.addSelectionListener(tableTreeListener);
> </code>
> Notice that only one is selected at this time, reason for ttis[0]...
Re: [MacOS X.3.6] TableTree getting selected item [message #446422 is a reply to message #446417] Wed, 24 November 2004 18:40 Go to previous message
Eclipse UserFriend
Originally posted by: yvon_thoraval.mac.com

Veronika Irvine a écrit :
> You need to call indexOf on the parent of the TableTreeItem. Sometimes this
> is the TableTree - when the item is a root node - and sometimes the parent
> is a TableTreeItem. The same applies for Tree and TreeItems.

OK, thanks, it seems that the index value also isn't what's expected, it
gives the leaf's index below last node or something the like (i had only
one node having leafs is this first trial)

Anyway, your help's very much appreciated.

Best,

Yvon
Previous Topic:handling a right mouse click over a TreeTable
Next Topic:Look and Feel of DirecotryDialog
Goto Forum:
  


Current Time: Tue Oct 20 23:48:10 GMT 2020

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

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

Back to the top