Selected row after remove [message #451016] |
Mon, 21 February 2005 10:22  |
Eclipse User |
|
|
|
Hello,
I was wondering what would be the best way to select the 'next' row in a
Tableviewer after the current row was removed with the
TableViewer.remove(Object) method.
Now when I call remove on a tableviewer, the selection is cleared and no
other row is selected. I would like to have the selection stay 'fixed'
on the current position (which is on the 'next' row after the removal of
the 'current' row). This would allow some kind of continuous removal.
I can't seem to find the proper methods or properties: no trace of
rowindeces in tableViewer and in table there is an indexOf which
requires a TableItem parameter. But how do I get a TableItem object?
Any suggestions would be welcome.
Thanks a lot.
Luc Feys
|
|
|
|
Re: Selected row after remove [message #451033 is a reply to message #451028] |
Tue, 22 February 2005 03:21  |
Eclipse User |
|
|
|
Roshan,
thanks for the reply. I was trying to perform this selection action from
my content provider (my structure is based on the tableViewer article on
eclipse website), but there I have no longer access to the current
selection, only to domain objects. But I guess the content provider is
not really the correct place to put view related code like that, so I
moved the code to my view where I do have access to the methods you
specified. Works fine now.
Thanks a lot.
Luc Feys
Roshan wrote:
> You will need to store the current index before deleting the row.
> Store it by calling
> tableViewer.getTable.getSelectionIndex();
>
> Delete the row
>
> Select the same row again by calling
>
> tableViewer.getTable.select(index);
>
> Remember to check for the index being within the number of elements so
> that you don't end up with an ArrayIndexOutOfBounds exception.
>
>
> Roshan
>
>
> Luc Feys wrote:
>
>> Hello,
>>
>> I was wondering what would be the best way to select the 'next' row in
>> a Tableviewer after the current row was removed with the
>> TableViewer.remove(Object) method.
>> Now when I call remove on a tableviewer, the selection is cleared and
>> no other row is selected. I would like to have the selection stay
>> 'fixed' on the current position (which is on the 'next' row after the
>> removal of the 'current' row). This would allow some kind of
>> continuous removal.
>> I can't seem to find the proper methods or properties: no trace of
>> rowindeces in tableViewer and in table there is an indexOf which
>> requires a TableItem parameter. But how do I get a TableItem object?
>>
>> Any suggestions would be welcome.
>>
>> Thanks a lot.
>>
>> Luc Feys
|
|
|
Powered by
FUDForum. Page generated in 0.03730 seconds