01: package fr.aliacom.form.swt.maker;
02:
03: import org.eclipse.swt.widgets.Shell;
04: import org.w3c.dom.Element;
05:
06: import fr.aliacom.commands.Command;
07: import fr.aliacom.commands.CommandPool;
08: import fr.aliacom.form.common.FormLoader;
09: import fr.aliacom.form.common.IForm;
10: import fr.aliacom.form.common.IFormComponent;
11: import fr.aliacom.form.swt.BuilderFactory;
12: import fr.aliacom.form.swt.SWTBuilder;
13: import fr.aliacom.form.swt.SWTForm;
14:
15: /**
16: * @author tom
17: *
18: * (C) 2001, 2002 Thomas Cataldo
19: */
20: public final class FormBuilder extends SWTBuilder {
21:
22: public IFormComponent build(Element elem, IFormComponent parent,
23: FormLoader loader, BuilderFactory factory) {
24:
25: SWTForm f = new SWTForm(null, (IForm) parent);
26: Shell sh = (Shell) f.getNativeWidget();
27:
28: f.setContext(loader.getCtx());
29: loader.getCtx().setForm(f);
30: f.setLoader(loader);
31: loader.setForm(f);
32:
33: buildChildren(elem, f, loader, factory);
34:
35: sh.setText(elem.getAttribute("title"));
36:
37: if (elem.hasAttribute("size")) {
38: String[] wh = elem.getAttribute("size").split("x");
39: int w = Integer.parseInt(wh[0]);
40: int h = Integer.parseInt(wh[1]);
41: sh.setSize(w, h);
42: log.debug("Setting size to " + w + "x" + h);
43: }
44:
45: if (elem.hasAttribute("loadAction")) {
46: Command c = CommandPool.getInstance().getCommand(f,
47: loader.getCtx(), elem.getAttribute("loadAction"));
48: f.setLoadCommand(c);
49: }
50:
51: return f;
52: }
53:
54: }
|