01: package fr.aliacom.form.swt.maker;
02:
03: import org.eclipse.swt.custom.SashForm;
04: import org.eclipse.swt.widgets.Composite;
05: import org.w3c.dom.Element;
06:
07: import fr.aliacom.form.common.IFormComponent;
08: import fr.aliacom.form.common.FormLoader;
09: import fr.aliacom.form.swt.BuilderFactory;
10: import fr.aliacom.form.swt.SWTBuilder;
11: import fr.aliacom.form.swt.ui.SWTSplitter;
12:
13: /**
14: * @author tom
15: *
16: * (C) 2001, 2002 Thomas Cataldo
17: */
18: public final class SplitterBuilder extends SWTBuilder {
19:
20: /**
21: * @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)
22: */
23: public IFormComponent build(Element elem, IFormComponent parent,
24: FormLoader loader, BuilderFactory factory) {
25: Composite c = (Composite) parent.getNativeWidget();
26: SWTSplitter split = new SWTSplitter(c, elem
27: .getAttribute("orientation"));
28:
29: buildChildren(elem, split, loader, factory);
30:
31: if (elem.getAttribute("weigth").length() > 0) {
32: String[] weigths = elem.getAttribute("weigth").split(",");
33: SashForm sf = (SashForm) split.getNativeWidget();
34: int[] w = new int[weigths.length];
35: for (int i = 0, n = weigths.length; i < n; i++) {
36: w[i] = Integer.parseInt(weigths[i]);
37: }
38: log.debug("Setting weights on splitter.");
39: sf.setWeights(w);
40: sf.pack();
41: }
42:
43: return split;
44: }
45:
46: }
|