Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How do I obtain an Object of a particular ROW in TreeViewer
icon2.gif  How do I obtain an Object of a particular ROW in TreeViewer [message #673669] Tue, 24 May 2011 12:45 Go to next message
Karan  is currently offline Karan Friend
Messages: 23
Registered: October 2009
Junior Member
Hi,

(In short)
In Content provider, we provide all the list of Objects and then the label provider displays them as usual.


Now, I want to click on a particular row's cell (which would have a button widget) and then I need to retrieve the "Object element" used for THAT row.

How do I do it...?? Confused
The reason being that I wish to perform operations on that Object subsequently thereby modifying the model and then call the update() method of the TreeViewer to reflect the model change back in the tree.


Any ideas?
Thx.
Re: How do I obtain an Object of a particular ROW in TreeViewer [message #674532 is a reply to message #673669] Fri, 27 May 2011 09:27 Go to previous messageGo to next message
tom  is currently offline tom Friend
Messages: 17
Registered: August 2010
Junior Member
ex) IStructuredSelection selected = (IStructuredSelection )viewer.getSelection();
if( selected.isEmpty() == true )
return;
Object obj = selected.getFirstElement();// you can get ,of course , first selected object.

Iterator it = selected.iterates() ;

while( it.hasNext() )
{
Object objIterated = it.next();//you can get all of Object you selected;
}

//////////////////////////////////// OR ///////////////////////////

TableItem[] items = viewer.getTable().getItems();

for( TableItem item : items )
{
Object obj = (Object)items.getData();
}
Re: How do I obtain an Object of a particular ROW in TreeViewer [message #677802 is a reply to message #674532] Thu, 09 June 2011 12:29 Go to previous message
Karan  is currently offline Karan Friend
Messages: 23
Registered: October 2009
Junior Member
HI Tom.. thank you very much.. i shall use the method as suggested by you..

I had actually checked.. "Notify on replies" but I never got a response !!

I just hap[pened to check and there was a reply!!

Thank you anyways ..


Regards,
Karan

[Updated on: Thu, 09 June 2011 12:29]

Report message to a moderator

Previous Topic:[Databinding] Master/Detail Validation Error
Next Topic:Check Data Binding Values
Goto Forum:
  


Current Time: Fri Nov 28 10:06:36 GMT 2014

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

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