Project: Eclipse_Platform_UI
Bug 104839 [Forms] TableWrapLayout requires too much vertical space with wrapped label in WizardPage
Reported: 2005-07-22 13:15:17 | Status: resolved fixed

My understanding is that the whole purpose of the TableWrapLayout is to deal with wrapped labels. But this example shows that the layout requests a height much greater than is required. I recently tested this in 3.1 - and it happened in 3.0 and 3.0.1, IIRC. Run the example and a Wizard will appear...which on my system takes up the entire height of the screen. Dismiss the Wizard and the 2nd example will appear: adding a textfield fixes the problem. But not really...as you can see in the 3rd example - multiple wrapped labels still force the wizard taller than it needs to be. Example code: package test; import org.eclipse.jface.wizard.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.*; import org.eclipse.ui.forms.widgets.*; /** */ public class MyWizardPage extends WizardPage { public MyWizardPage(int variation) { super("intro"); setTitle("title"); setDescription("description"); _variation = variation; } public void createControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); // toolkit.setBackground(parent.getBackground()); form = toolkit.createForm(parent); form.setText("prompt"); setControl(form); Composite body = form.getBody(); TableWrapLayout layout = new TableWrapLayout(); layout.numColumns = 2; layout.verticalSpacing = 10; layout.topMargin = 10; layout.bottomMargin = 10; layout.leftMargin = 10; layout.rightMargin = 10; body.setLayout(layout); Label label1 = toolkit.createLabel(body, "Here is a long line. It is pretty long. Well, long enough to wrap in the wizard, anyway. It goes on and on an on for no particular purpose, really. It just keeps going. Kinda like that bunny in those battery commercials.", SWT.WRAP); label1.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.CENTER, 1, 2)); if (_variation == 3) { Label label2 = toolkit.createLabel(body, "Here is a long line. It is pretty long. Well, long enough to wrap in the wizard, anyway. It goes on and on an on for no particular purpose, really. It just keeps going. Kinda like that bunny in those battery commercials.", SWT.WRAP); label2.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.CENTER, 1, 2)); Label label3 = toolkit.createLabel(body, "Here is a long line. It is pretty long. Well, long enough to wrap in the wizard, anyway. It goes on and on an on for no particular purpose, really. It just keeps going. Kinda like that bunny in those battery commercials.", SWT.WRAP); label3.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.CENTER, 1, 2)); } if (_variation > 1) { Text _url_field = toolkit.createText(body, "Adding this text field fixed the problem! Why?", SWT.BORDER); _url_field.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); } } public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("testing..."); shell.pack(); shell.open(); createWizard(shell, 1); createWizard(shell, 2); createWizard(shell, 3); } private static void createWizard(Shell shell, int variation) { Wizard wizard = new Wizard() { public boolean performFinish() { return true; //To change body of implemented methods use File | Settings | File Templates. } }; wizard.addPage(new MyWizardPage(variation)); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); } public void dispose() { super.dispose(); toolkit.dispose(); } private FormToolkit toolkit; private Form form; int _variation; }

Files changed in fix:
bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapLayout.java