Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Initial selection problem on TableViewer
Initial selection problem on TableViewer [message #459314] Fri, 05 August 2005 08:13 Go to next message
Eclipse UserFriend
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 14:46 Go to previous messageGo to next message
Eclipse UserFriend
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 15:51 Go to previous messageGo to next message
Eclipse UserFriend
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 17:17 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 03:33:45 EDT 2025

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

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

Back to the top