Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to update view size when new widgets are added?
How to update view size when new widgets are added? [message #488111] Fri, 25 September 2009 15:18 Go to next message
Frank Du is currently offline Frank DuFriend
Messages: 91
Registered: July 2009
Member
Dear All,

I encountered a layout size issue with PageBook. Here is the widgets in my views:

UI form view:
-------------------------
Table1
PageBook1


Table1 has 10 items. When a table item is selected, PageBook1 shows relative page control. The page controls are in different sizes. Therefore it means that PageBook1 needs to change size and update its view part. How can I achieve this?

I have tried to call form.reflow(true), but the PageBook size remains a single row.

Thank you so much! Have a nice weekend!

Regards,
Frank
Re: How to update view size when new widgets are added? [message #488160 is a reply to message #488111] Fri, 25 September 2009 17:49 Go to previous messageGo to next message
Frank Du is currently offline Frank DuFriend
Messages: 91
Registered: July 2009
Member
To clarify the problem, here I upload the screen shot.

The heights of PageBook controls change according to table selection. Currently I use a vertical scroll bar for height changes.

However, is there a way to grow size of view form height, instead of using a vertical scroll bar?

Thanks so much!

Regards,
Frank Du
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 Go to previous message
Frank Du is currently offline Frank DuFriend
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
Previous Topic:How to drag to reorder TabItem in a TabFolder?
Next Topic:Adding code folding to a ProjectionViewer
Goto Forum:
  


Current Time: Fri Apr 19 10:33:26 GMT 2024

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

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

Back to the top