01: package fr.aliacom.form.swt.maker;
02:
03: import org.eclipse.swt.widgets.Composite;
04: import org.w3c.dom.Element;
05:
06: import fr.aliacom.commands.Command;
07: import fr.aliacom.commands.CommandPool;
08: import fr.aliacom.common.ui.table.TableModel;
09: import fr.aliacom.form.common.FormComponentLoader;
10: import fr.aliacom.form.common.FormLoader;
11: import fr.aliacom.form.common.IFormComponent;
12: import fr.aliacom.form.swt.BuilderFactory;
13: import fr.aliacom.form.swt.SWTBuilder;
14: import fr.aliacom.form.swt.ui.SWTTable;
15:
16: /**
17: * @author tom
18: *
19: * (C) 2001, 2002 Thomas Cataldo
20: */
21: public final class TableBuilder 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: TableModel tableModel = new TableModel();
29:
30: SWTTable table = new SWTTable((Composite) parent
31: .getNativeWidget(), tableModel);
32:
33: buildChildren(elem, table, loader, factory);
34: if (elem.hasAttribute("onSelect")) {
35: Command c = CommandPool.getInstance().getCommand(
36: loader.getForm(), loader.getCtx(),
37: elem.getAttribute("onSelect"));
38: table.setOnSelectAction(c);
39: }
40:
41: table.createUIFromModel();
42: loader.addLoader(elem.getAttribute("rows"),
43: new FormComponentLoader(table));
44: return table;
45: }
46:
47: }
|