Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem with ScrolledPageBook, SashFom and TableViewer combined
Problem with ScrolledPageBook, SashFom and TableViewer combined [message #753679] Fri, 28 October 2011 06:18 Go to next message
Setya Mising name is currently offline Setya Mising name
Messages: 486
Registered: July 2009
Senior Member
Hi all,

I put a TableViewer in a SashForm's left panel and the SashForm is hosted by ScrolledPageBook, when the TableViewer's rows exceed its height, a vertical scrollbar is not drawn instead it stretches the SashForm's panel.

To further explain the problem please execute the following snippets:
...
@Override
public void createPartControl(Composite parent)
{
parent.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(5, 5, 5, 5).create());
	  
ScrolledPageBook pageBook = toolkit.createPageBook(parent, SWT.NONE);
pageBook.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

Composite page = pageBook.createPage("firstPage");	  
page.setLayout(GridLayoutFactory.fillDefaults().create());
	  
SashForm sash = new SashForm(page, SWT.HORIZONTAL | SWT.NULL);
toolkit.adapt(sash, true, true);
sash.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
sash.setSashWidth(5);

TableViewer tableViewer = new TableViewer(toolkit.createTable(sash, SWT.SINGLE | SWT.BORDER));
tableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
tableViewer.setContentProvider(createTableContentProvider());
tableViewer.setLabelProvider(new LabelProvider());
	  
Composite rightPanel = toolkit.createComposite(sash);
rightPanel.setLayout(GridLayoutFactory.fillDefaults().create());
rightPanel.setLayoutData(GridDataFactory.fillDefaults().grab(true, true));
	  
Composite client = toolkit.createComposite(rightPanel, SWT.BORDER);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    
client = toolkit.createComposite(rightPanel, SWT.BORDER);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    
sash.setWeights(new int[]{30, 70});

//Fill the table with 2 rows
//tableViewer.setInput(Arrays.asList("Item 1", "Item 2"));
	  
//Fill the table with 100 rows
java.util.List<String> longList = new LinkedList<String>();
for (int i = 0; i < 50; i++)
  longList.add("Item " + (i+1));
		
tableViewer.setInput(longList);

pageBook.showPage("firstPage");
}

private IContentProvider createTableContentProvider()
{
return new IStructuredContentProvider()
{
public void inputChanged(Viewer viewer, Object oldInput, Object newInput){}
public void dispose(){}
			
@SuppressWarnings("rawtypes")
public Object[] getElements(Object element){return element != null ? ((java.util.List)element).toArray() : new Object[]{};}
};
}
...


From above snippet play with the number of data stuffed into the TableViewer or change the SashForm to be directly hosted by Composite instead of ScrolledPageBook and see the difference.

Any help would be greatly appreciated.

Thanks & Regards,

Setya
Re: Problem with ScrolledPageBook, SashFom and TableViewer combined [message #753686 is a reply to message #753679] Fri, 28 October 2011 07:07 Go to previous message
Setya Mising name is currently offline Setya Mising name
Messages: 486
Registered: July 2009
Senior Member
Some screenshots attached:

1. TableViewer with some rows.
2. TableViewer with many rows.


Regards,

Setya
Previous Topic:libxul.so: undefined symbol: gtk_major_version
Next Topic:Accessing Properties of Custom Dialog
Goto Forum:
  


Current Time: Sat Aug 23 15:57:38 EDT 2014

Powered by FUDForum. Page generated in 0.01568 seconds