01: package fr.aliacom.form.swt.maker;
02:
03: import org.w3c.dom.Element;
04:
05: import fr.aliacom.commands.Command;
06: import fr.aliacom.commands.CommandPool;
07: import fr.aliacom.form.common.FormComponentLoader;
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.SWTText;
13:
14: /**
15: * @author tom
16: *
17: * (C) 2001, 2003 Thomas Cataldo
18: */
19: public class TextBuilder extends SWTBuilder {
20:
21: /**
22: * @see fr.aliacom.form.swt.SWTBuilder#build(org.w3c.dom.Element, fr.aliacom.form.common.IFormComponent, fr.aliacom.form.common.FormLoader, fr.aliacom.form.swt.BuilderFactory)
23: */
24: public IFormComponent build(Element elem, IFormComponent parent,
25: FormLoader loader, BuilderFactory factory) {
26: int length = (elem.hasAttribute("length") ? Integer
27: .parseInt(elem.getAttribute("length")) : 10);
28: SWTText text = new SWTText(parent, elem
29: .getAttribute("property"), length);
30:
31: if (elem.hasAttribute("editable")) {
32: text.setEditable(elem.getAttribute("editable").equals(
33: "true") ? true : false);
34: }
35: if (elem.hasAttribute("enabled")) {
36: text
37: .setEnabled(elem.getAttribute("enabled").equals(
38: "true") ? true : false);
39: }
40: if (elem.hasAttribute("onCr")) {
41: Command c = CommandPool.getInstance().getCommand(
42: loader.getForm(), loader.getCtx(),
43: elem.getAttribute("onCr"));
44: text.setOnCrAction(c);
45: }
46: if (elem.hasAttribute("onDown")) {
47: Command c = CommandPool.getInstance().getCommand(
48: loader.getForm(), loader.getCtx(),
49: elem.getAttribute("onDown"));
50: text.setOnDownAction(c);
51: }
52: if (elem.hasAttribute("onUp")) {
53: Command c = CommandPool.getInstance().getCommand(
54: loader.getForm(), loader.getCtx(),
55: elem.getAttribute("onUp"));
56: text.setOnUpAction(c);
57: }
58:
59: loader.addLoader(elem.getAttribute("bean"),
60: new FormComponentLoader(text));
61: return text;
62: }
63:
64: }
|