X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/LayoutUtil.java index 2abec85..baee413 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/LayoutUtil.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/LayoutUtil.java @@ -17,124 +17,143 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; public class LayoutUtil { - + /** * Calculates the number of columns needed by field editors */ public static int getNumberOfColumns(DialogField[] editors) { - int nCulumns= 0; - for (int i= 0; i < editors.length; i++) { - nCulumns= Math.max(editors[i].getNumberOfControls(), nCulumns); + int nCulumns = 0; + for (int i = 0; i < editors.length; i++) { + nCulumns = Math.max(editors[i].getNumberOfControls(), nCulumns); } return nCulumns; } - + /** * Creates a composite and fills in the given editors. - * @param labelOnTop Defines if the label of all fields should be on top of the fields - */ - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop) { + * + * @param labelOnTop + * Defines if the label of all fields should be on top of the + * fields + */ + public static void doDefaultLayout(Composite parent, DialogField[] editors, + boolean labelOnTop) { doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0); } /** * Creates a composite and fills in the given editors. - * @param labelOnTop Defines if the label of all fields should be on top of the fields - * @param minWidth The minimal width of the composite - * @param minHeight The minimal height of the composite + * + * @param labelOnTop + * Defines if the label of all fields should be on top of the + * fields + * @param minWidth + * The minimal width of the composite + * @param minHeight + * The minimal height of the composite */ - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight) { + public static void doDefaultLayout(Composite parent, DialogField[] editors, + boolean labelOnTop, int minWidth, int minHeight) { doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0); } /** * Creates a composite and fills in the given editors. - * @param labelOnTop Defines if the label of all fields should be on top of the fields - * @param minWidth The minimal width of the composite - * @param minHeight The minimal height of the composite - * @param marginWidth The margin width to be used by the composite - * @param marginHeight The margin height to be used by the composite + * + * @param labelOnTop + * Defines if the label of all fields should be on top of the + * fields + * @param minWidth + * The minimal width of the composite + * @param minHeight + * The minimal height of the composite + * @param marginWidth + * The margin width to be used by the composite + * @param marginHeight + * The margin height to be used by the composite * @deprecated - */ - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight, int marginWidth, int marginHeight) { - int nCulumns= getNumberOfColumns(editors); - Control[][] controls= new Control[editors.length][]; - for (int i= 0; i < editors.length; i++) { - controls[i]= editors[i].doFillIntoGrid(parent, nCulumns); + */ + public static void doDefaultLayout(Composite parent, DialogField[] editors, + boolean labelOnTop, int minWidth, int minHeight, int marginWidth, + int marginHeight) { + int nCulumns = getNumberOfColumns(editors); + Control[][] controls = new Control[editors.length][]; + for (int i = 0; i < editors.length; i++) { + controls[i] = editors[i].doFillIntoGrid(parent, nCulumns); } if (labelOnTop) { nCulumns--; modifyLabelSpans(controls, nCulumns); } - GridLayout layout= new GridLayout(); + GridLayout layout = new GridLayout(); if (marginWidth != SWT.DEFAULT) { - layout.marginWidth= marginWidth; + layout.marginWidth = marginWidth; } if (marginHeight != SWT.DEFAULT) { - layout.marginHeight= marginHeight; + layout.marginHeight = marginHeight; } - layout.numColumns= nCulumns; + layout.numColumns = nCulumns; parent.setLayout(layout); } - + private static void modifyLabelSpans(Control[][] controls, int nCulumns) { - for (int i= 0; i < controls.length; i++) { + for (int i = 0; i < controls.length; i++) { setHorizontalSpan(controls[i][0], nCulumns); } } - + /** * Sets the span of a control. Assumes that GridData is used. */ public static void setHorizontalSpan(Control control, int span) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).horizontalSpan= span; + ((GridData) ld).horizontalSpan = span; } else if (span != 1) { - GridData gd= new GridData(); - gd.horizontalSpan= span; + GridData gd = new GridData(); + gd.horizontalSpan = span; control.setLayoutData(gd); } - } + } /** * Sets the width hint of a control. Assumes that GridData is used. */ public static void setWidthHint(Control control, int widthHint) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).widthHint= widthHint; + ((GridData) ld).widthHint = widthHint; } } - + /** * Sets the heigthHint hint of a control. Assumes that GridData is used. */ public static void setHeigthHint(Control control, int heigthHint) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).heightHint= heigthHint; + ((GridData) ld).heightHint = heigthHint; } - } - + } + /** * Sets the horizontal indent of a control. Assumes that GridData is used. */ public static void setHorizontalIndent(Control control, int horizontalIndent) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).horizontalIndent= horizontalIndent; + ((GridData) ld).horizontalIndent = horizontalIndent; } } - + /** * Sets the horizontal indent of a control. Assumes that GridData is used. */ public static void setHorizontalGrabbing(Control control) { - Object ld= control.getLayoutData(); + Object ld = control.getLayoutData(); if (ld instanceof GridData) { - ((GridData)ld).grabExcessHorizontalSpace= true; + ((GridData) ld).grabExcessHorizontalSpace = true; } - } + } }