01: package fr.aliacom.form.swt.maker;
02:
03: import java.util.Iterator;
04:
05: import org.eclipse.swt.SWT;
06: import org.eclipse.swt.custom.CTabFolder;
07: import org.eclipse.swt.custom.CTabItem;
08: import org.eclipse.swt.widgets.Control;
09: import org.w3c.dom.Element;
10:
11: import fr.aliacom.form.common.FormLoader;
12: import fr.aliacom.form.common.IFormComponent;
13: import fr.aliacom.form.swt.BuilderFactory;
14: import fr.aliacom.form.swt.SWTBuilder;
15:
16: /**
17: * @author tom
18: *
19: * (C) 2001, 2002 Thomas Cataldo
20: */
21: public final class TabBuilder extends SWTBuilder {
22:
23: /**
24: * @see fr.aliacom.form.swt.SWTBuilder#build(Element, IFormComponent, FormLoader, BuilderFactory)
25: */
26: public IFormComponent build(Element elem, IFormComponent parent,
27: FormLoader loader, BuilderFactory factory) {
28: CTabItem tab = new CTabItem((CTabFolder) parent
29: .getNativeWidget(), SWT.NULL);
30: String tabText = getNodeText(elem);
31: tab.setText(tabText);
32: System.out.println("Tab text is '" + tabText + "'");
33:
34: /* build the tab child (one per tab) */
35: Iterator it = new ElementIterator(elem.getChildNodes());
36: Element cur = (Element) it.next();
37: SWTBuilder builder = factory.getBuilder(cur.getNodeName());
38: Control control = (Control) builder.build(cur, parent, loader,
39: factory).getNativeWidget();
40: tab.setControl(control);
41: control.pack();
42:
43: return null; // parent is a tab folder
44: }
45:
46: }
|