Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Selected row after remove
Selected row after remove [message #451016] Mon, 21 February 2005 10:22 Go to next message
Eclipse UserFriend
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 #451028 is a reply to message #451016] Mon, 21 February 2005 16:34 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Selected row after remove [message #451033 is a reply to message #451028] Tue, 22 February 2005 03:21 Go to previous message
Eclipse UserFriend
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
Previous Topic:Question about ImageLoader or Java in general...
Next Topic:Disabling the changing of tabs in a CTabFolder.
Goto Forum:
  


Current Time: Tue Jul 01 18:22:01 EDT 2025

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

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

Back to the top