Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » how to select row number in JFace TableViewer
how to select row number in JFace TableViewer [message #331180] Wed, 27 August 2008 16:35 Go to next message
jtalafous is currently offline jtalafousFriend
Messages: 5
Registered: July 2009
Junior Member
org.eclipse.jface.viewers.TableViewer's super (StructuredViewer) has this
method: public void setSelection(ISelection selection, boolean reveal),
but all I want is to select the i-th row in the TableViewer. What is the
best way to do it? Why isn't there a method called setSelection(int row)?
Thanks!
Re: how to select row number in JFace TableViewer [message #331183 is a reply to message #331180] Wed, 27 August 2008 16:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
viewer.setSelection(new StructuredSelection(viewer.getElementAt(pos)),true);

Tom

newbie from swing schrieb:
>
> org.eclipse.jface.viewers.TableViewer's super (StructuredViewer) has
> this method: public void setSelection(ISelection selection, boolean
> reveal), but all I want is to select the i-th row in the TableViewer.
> What is the best way to do it? Why isn't there a method called
> setSelection(int row)? Thanks!
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: how to select row number in JFace TableViewer [message #331341 is a reply to message #331183] Tue, 02 September 2008 16:06 Go to previous messageGo to next message
jtalafous is currently offline jtalafousFriend
Messages: 5
Registered: July 2009
Junior Member
viewer.setSelection(new
StructuredSelection(viewer.getElementAt(pos)),true);

Thank you very much. This solution works great for an eager loading
Table. However, when I convert the Table to lazy loading with
SWT.VIRTUAL, viewer.getElementAt(pos) returns null. Does the current
version provide a solution to this, and if so, could you give me a hint to
research? Thanks!
Re: how to select row number in JFace TableViewer [message #331342 is a reply to message #331341] Tue, 02 September 2008 16:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well, you can maybe use the SWT-API:

Table#setTopIndex(int) => Scrolls item into view => Materialize =>
Table#getItem()#getData() holds your model element => you can set the
selection.

This is just theory so I can guarantee that it works at all.

Tom

newbie from swing schrieb:
> viewer.setSelection(new
> StructuredSelection(viewer.getElementAt(pos)),true);
>
> Thank you very much. This solution works great for an eager loading
> Table. However, when I convert the Table to lazy loading with
> SWT.VIRTUAL, viewer.getElementAt(pos) returns null. Does the current
> version provide a solution to this, and if so, could you give me a hint
> to research? Thanks!
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: how to select row number in JFace TableViewer [message #331431 is a reply to message #331342] Fri, 05 September 2008 17:18 Go to previous message
jtalafous is currently offline jtalafousFriend
Messages: 5
Registered: July 2009
Junior Member
Thank you, that is a great idea! I tried hard to implement it, and it I
just can't get the elements to "materialize" as they say in the literature.

So I punted and used KTable from Sourceforge. It worked pretty well for
two reasons. It lets me manipulate rows based on index, i.e., it is
index-based instead of object-based. And it is always lazy loading, even
for small tables.

Still am wondering why I can't get it to materialize, but have to hit a
deadline. :( Thanks
Previous Topic:Platform-specific fragments not dl'ed from update site in 3.4?
Next Topic:returning an exit code
Goto Forum:
  


Current Time: Wed Jul 17 19:38:24 GMT 2024

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

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

Back to the top