select the last added row in a table [message #501687] |
Thu, 03 December 2009 08:30  |
Eclipse User |
|
|
|
Hi,
I've got a tableviewer within a view that is based on a WritableList model. I'd like to programmatically select the last added row in the model, but I don't know what is the best practice for doing this. The model is wrapped in the table content provider, and a new line is added thru an editor, so do I need to make the content provider aware of the table viewer it is serving (so to set the selection on it when a new element is added)?
Is there any better way of doing it?
Thanks,
Luca
|
|
|
Re: select the last added row in a table [message #501821 is a reply to message #501687] |
Thu, 03 December 2009 17:24   |
Eclipse User |
|
|
|
Hi Luca,
I am not certain what you want exactly but your question I can answer. The
inputChanged method of your content provider passes the viewer. You can cast
that to your viewer (table, tree, etc..) and work with it.
--
Best Regards,
Wim Jongman
-- The fear of loss is a path to the Dark Side.
YODA, Star Wars Episode III: Revenge of the Sith
> Hi,
> I've got a tableviewer within a view that is based on a WritableList model.
I'd like to programmatically select the last added row in the model, but I
don't know what is the best practice for doing this. The model is wrapped in
the table content provider, and a new line is added thru an editor, so do I
need to make the content provider aware of the table viewer it is serving (so
to set the selection on it when a new element is added)?
> Is there any better way of doing it?
>
> Thanks,
> Luca
|
|
|
Re: select the last added row in a table [message #504548 is a reply to message #501821] |
Mon, 21 December 2009 08:24  |
Eclipse User |
|
|
|
What I want to do is that once the editor saves the data (that is displayed in a table) the latest added/modified row is selected again (the row could be removed and re-added on the fly). In order to achieve this I've placed a method in my view that embeds the table viewer:
public final void selectTableRow( int index ){
this.getTableViewer().getTable().setSelection(index);
}
then the editor, while saving the data, performs this last operation in the save method:
IViewPart launchingView = this.getSite().getPage().findView( ((BaseEditorInput) this.getEditorInput()).getLaunchingViewID() );
if( launchingView instanceof BaseTableView )
((BaseTableView) launchingView ).selectTableRow(modifiedRowIndex);
The idea is that the editor input has the platform id of the view from which the editor is opened and it selects the inserted row (modifiedRowIndex).
|
|
|
Powered by
FUDForum. Page generated in 0.02994 seconds