Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Initial selection problem on TableViewer
Initial selection problem on TableViewer [message #459314] Fri, 05 August 2005 12:13 Go to next message
jfeid is currently offline jfeidFriend
Messages: 21
Registered: July 2009
Junior Member
Hi all,

I'm using a TableViewer control on a WizardPage. On createControl I
construct
the TableViewer as normal:

viewer = new TableViewer( comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
viewer.setContentProvider( new MyContentProvider() );
viewer.setLabelProvider( new MyLabelProvider() );
viewer.setInput( myRootModelObject );

Now, the simple thing I want to achieve is to set the selection on the
viewer based on a selection made on another view (they share the same
model) by the user. So, supposedly my getUserSelection service gets the
user selection, all I have to do is to:

ISelection selection = getUserSelection();
viewer.setSelection(selection, true);

Unfortunately, this does not work, simply because the viewer is not yet
populated with elements at the time the setSelection method is called (on
createControl).
Is there a way to be notified that the viewer has been populated in order
to call setSelection right after?

Any help would be appreciated.
Thank a lot.
Re: Initial selection problem on TableViewer [message #459331 is a reply to message #459314] Fri, 05 August 2005 18:46 Go to previous messageGo to next message
Chris is currently offline ChrisFriend
Messages: 12
Registered: July 2009
Junior Member
Can't you just use a flag ( i.e. boolean value) to indicate to
setSelection as to whether or not the table is populated? So, the flag is
initially set to false, and if the flag is set to false then the
setSelection does not get called....otherwise, when the flag is true the
setSelection is called.
Re: Initial selection problem on TableViewer [message #459333 is a reply to message #459331] Fri, 05 August 2005 19:51 Go to previous messageGo to next message
jfeid is currently offline jfeidFriend
Messages: 21
Registered: July 2009
Junior Member
Thanx for your answer Christian. I will try it.
Re: Initial selection problem on TableViewer [message #459334 is a reply to message #459333] Fri, 05 August 2005 21:17 Go to previous message
jfeid is currently offline jfeidFriend
Messages: 21
Registered: July 2009
Junior Member
Unfortunately, there is no way to check when the table viewer is
populated. I could only start a timer inside ContentProvider's
getElements(Object inputElement) with a reasonable hit time in order to be
"certain" that the population is done. It is suprisingly weird how such a
simple feature is so difficult to implement. Unless i'm missing something
basic about TableViewer's working.
Previous Topic:Image space for TreeViewer with ITableLabelProvider
Next Topic:TreeItem.setExpanded() not showing the desired effect
Goto Forum:
  


Current Time: Tue Oct 20 07:35:38 GMT 2020

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

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

Back to the top