Skip to main content


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 10:18 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
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 11:07 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
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: Fri Apr 19 08:17:48 GMT 2024

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

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

Back to the top