Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » select the last added row in a table(tableviewer and writablelist selection after an add operation in the model)
select the last added row in a table [message #501687] Thu, 03 December 2009 13:30 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
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 22:24 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
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 13:24 Go to previous message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
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).
Previous Topic:corrupted eclipse JAR signature?
Next Topic:After creating application (plugin), change default 'workspace data' location
Goto Forum:
  


Current Time: Tue Apr 16 07:02:21 GMT 2024

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

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

Back to the top