TableViewer Reveal / setSelection(....,true) [message #89879] |
Mon, 26 May 2008 04:11  |
Eclipse User |
|
|
|
Hi,
it seems that the reveal method of the table viewer does not work correctly
if these methods are called when the viewer is create (i.e. in method
createPartControl). Doing it there the correct element is selected, but not
revealed. The viewer seems to be position about two items to low!
You can reproduce the problem by changing DemoTableViewPart to have 240 rows
(just a numbe I used for my tests) and calling the following code right
after getSite().setSelectionProvider(viewer):
Object element = buffer.get(buffer.size() -30);
viewer.setSelection(new StructuredSelection(element), true);
viewer.reveal(element);
Calling these methods by an additional button will do a correct reveal, but
that doesn't help, if you want to initially select an item and reveal it.
Regards,
Markus
|
|
|
Re: TableViewer Reveal / setSelection(....,true) [message #89924 is a reply to message #89879] |
Mon, 26 May 2008 04:50   |
Eclipse User |
|
|
|
Hi Markus,
although this isn't the answer to your question: If your TableViewer is
Virtual and you're dealing with a larger amount of data, I would NOT
recommend to use TableViewer#setSelection. This is because the current
(JFace and RAP) implementation starts getting all elements from the model
in setSelection().
This means, that
- each model element is fetched and kept in memory, even if only the first
item should be selected.
- for each model element a TableItem is rendered to the browser which
decreases browser performance.
Instead, you can set the selection on the RWT layer using
TableViewer.getTable.setSelection, however, the JFace Selection events
aren't fired in this case.
Regards,
Stefan.
|
|
|
Re: TableViewer Reveal / setSelection(....,true) [message #90147 is a reply to message #89879] |
Mon, 26 May 2008 18:38   |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Hi Markus,
what do you mean with 'seems to be position about two items to low'?
Is the item visible but not at the position you would expected it,
or isn't it visible at all?
The documentation only states that reveal 'ensures that the given
element is visible'.
However, feel free to open a bugzilla if the item isn't visible at
all or you think it should show at a different position.
Cheers,
Rüdiger
Markus Krüger wrote:
> Hi,
> it seems that the reveal method of the table viewer does not work correctly
> if these methods are called when the viewer is create (i.e. in method
> createPartControl). Doing it there the correct element is selected, but not
> revealed. The viewer seems to be position about two items to low!
> You can reproduce the problem by changing DemoTableViewPart to have 240 rows
> (just a numbe I used for my tests) and calling the following code right
> after getSite().setSelectionProvider(viewer):
>
> Object element = buffer.get(buffer.size() -30);
> viewer.setSelection(new StructuredSelection(element), true);
> viewer.reveal(element);
>
> Calling these methods by an additional button will do a correct reveal, but
> that doesn't help, if you want to initially select an item and reveal it.
>
> Regards,
> Markus
>
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 3.43858 seconds