how to select row number in JFace TableViewer [message #331180] |
Wed, 27 August 2008 16:35  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.24785 seconds