|
|
Re: How to update view size when new widgets are added? [message #488194 is a reply to message #488111] |
Fri, 25 September 2009 20:36 |
Frank Du Messages: 91 Registered: July 2009 |
Member |
|
|
Finally I figure it out. Below is the code snippet for someone who is interested in it. Please note: the last 4 statements are very important. They will do:
1. compute desired size for the widget
2. update the layout data
3. call layout() on the widget
4. reflow the form view
myTable.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
Composite parent = toolkit.createComposite(pageBook);
parent.setLayout(new GridLayout(1, false));
int index = myTable.getSelectedIndex();
MStep step = .....
for(int i=0; i<(index+1)*5; i++){
toolkit.createLabel(parent, "hello world: " + step.getName());
toolkit.createText(parent, "text to be added: " + step.getConfigId());
}
pageBook.showPage(parent);
Point computeSize = pageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
GridDataFactory.defaultsFor(pageBook).align(SWT.FILL, SWT.TOP).span(2, 1).hint(SWT.DEFAULT, computeSize.y + 50).applyTo(pageBook);
pageBook.layout(true, true);
form.reflow(true);
}
});
Regards,
Frank Du
------------------
Blogs about RCP: http://www.frankdu.com/weblog
|
|
|
Powered by
FUDForum. Page generated in 0.02562 seconds