Problem with ScrolledPageBook, SashFom and TableViewer combined [message #753679] |
Fri, 28 October 2011 10:18 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03908 seconds