01: package fr.aliacom.form.swt.maker;
02:
03: import org.eclipse.swt.SWT;
04: import org.eclipse.swt.layout.GridLayout;
05: import org.eclipse.swt.widgets.Composite;
06: import org.w3c.dom.Element;
07:
08: import fr.aliacom.form.common.FormLoader;
09: import fr.aliacom.form.common.IFormComponent;
10: import fr.aliacom.form.swt.BuilderFactory;
11: import fr.aliacom.form.swt.SWTBuilder;
12: import fr.aliacom.form.swt.ui.SWTComposite;
13:
14: /**
15: * @author tom
16: *
17: * (C) 2001, 2002 Thomas Cataldo
18: */
19: public final class GridBuilder extends SWTBuilder {
20:
21: /**
22: * @see fr.aliacom.form.swt.SWTBuilder#build(Element, IFormComponent, FormLoader, BuilderFactory)
23: */
24: public IFormComponent build(Element elem, IFormComponent parent,
25: FormLoader loader, BuilderFactory factory) {
26: Composite parentWidget = (Composite) parent.getNativeWidget();
27: Composite comp = new Composite(parentWidget, SWT.NONE);
28: IFormComponent ret = new SWTComposite(comp);
29: GridLayout layout = new GridLayout();
30: int border = 0;
31: if (elem.hasAttribute("border")) {
32: border = Integer.parseInt(elem.getAttribute("border"));
33: }
34: layout.marginHeight = border;
35: layout.marginWidth = border;
36: layout.makeColumnsEqualWidth = false;
37: layout.numColumns = Integer.parseInt(elem
38: .getAttribute("columns"));
39: comp.setLayout(layout);
40:
41: buildChildren(elem, ret, loader, factory);
42:
43: return ret;
44: }
45:
46: }
|