| no scrollbars when expanding section with managedform.reflow() [message #452174] | 
Mon, 14 March 2005 20:21   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I'm using the form programming sample code from the 
org.eclipse.ui.forms.examples plugin, and have modified the 
MasterDetailsBlock page so that TyepOneDetailsPage contains an expandable 
section.  My two code changes are shown with '*' below. 
 
I cannot figure out why expanding the section s1 doesn't result in 
scrollbars appearing - I thought the mform.reflow() in my expansion 
listener should do that. 
 
Scrollbars *do* appear when I select a new item in the sample's master 
part, so there's definitely a scrollable parent in the widget hierarchy, I 
just cannot trigger the addition of scrollbars with mform.reflow().  What 
should I be calling in the expansion listener? 
 
public void createContents(Composite parent) { 
	TableWrapLayout layout = new TableWrapLayout(); 
	layout.topMargin = 5; 
	layout.leftMargin = 5; 
	layout.rightMargin = 2; 
	layout.bottomMargin = 2; 
	parent.setLayout(layout); 
	FormToolkit toolkit = mform.getToolkit(); 
	Section s1 = toolkit.createSection(parent, 
		Section.DESCRIPTION| 
*		Section.TWISTIE|Section.COMPACT); 
	s1.marginWidth = 10; 
	s1.setText("Type One Details"); 
	s1.setDescription("Set the properties of the selected TypeOne object."); 
	TableWrapData td = new TableWrapData(TableWrapData.FILL, 
	TableWrapData.TOP); td.grabHorizontal = true; 
	s1.setLayoutData(td); 
	toolkit.createCompositeSeparator(s1); Composite client = 
	toolkit.createComposite(s1); GridLayout glayout = new GridLayout(); 
	glayout.marginWidth = glayout.marginHeight = 0; glayout.numColumns = 2; 
	client.setLayout(glayout); 
	 
*	s1.addExpansionListener(new ExpansionAdapter() { 
		public void expansionStateChanged(ExpansionEvent e) { 
			mform.reflow(true); 
		} 
	}); 
	... [rest of app is same as sample code]
 |  
 |  
  | 
 | 
 | 
| Re: no scrollbars when expanding section with managedform.reflow () [message #452292 is a reply to message #452278] | 
Wed, 16 March 2005 21:28    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Thanks Dimitry, 
 
That does the trick.  I spent a lot of hours on this one, and to be 
honest, I still don't fully understand the distinctions between reflow(), 
layout(), pack(), redraw(), etc., nor how they propagate up/down a 
hierarchy of SWT components/forms.  It would be good if somebody in the 
know could write a little on these - I have colleagues who have also spent 
a lot of time fiddling with reflow() and layout(). 
 
I think you're right.  For some reason, the mform.reflow() doesn't affect 
the ScrolledComposite.  Seems like a bug to me. 
 
The other curious thing about this is that the expanding section  
sends a reflow() up the hierarchy by default, but this also does nothing 
to the scrollbars. 
 
For the benefit of others, here're the other things that I tried in my 
expansion handler, to no avail: 
 
public void expansionStateChanged(ExpansionEvent e) { 
 
 // exifSection.layout(true); 
 // exifSection.pack(true); 
 // exifSection.notifyListeners(SWT.Resize, new Event()); 
			 
 // mform.reflow(true); 
 // mform.getForm().layout(); 
 // mform.getForm().reflow(true); // This is what mform.reflow() does 
 // mform.getForm().redraw(); 
 // mform.getForm().notifyListeners(SWT.Resize, new Event()); 
                 
 // parent.getParent().getParent().layout(true); 
  ((SharedScrolledComposite)(parent.getParent().getParent())). reflow(true);                 
}
 |  
 |  
  | 
 | 
Powered by 
FUDForum. Page generated in 0.51970 seconds