01: package fr.aliacom.form.swt.maker;
02:
03: import org.w3c.dom.Element;
04:
05: import fr.aliacom.common.ui.table.ColumnView;
06: import fr.aliacom.common.ui.table.ILabelProvider;
07: import fr.aliacom.common.ui.table.LabelRenderer;
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:
13: /**
14: * @author tom
15: *
16: * (C) 2001, 2003 Thomas Cataldo
17: */
18: public final class LabelRendererBuilder 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: ColumnView view = (ColumnView) parent;
26: view.setRenderer(new LabelRenderer(createProvider(elem)));
27: return null;
28: }
29:
30: /**
31: * Method createRenderer.
32: * @param elem
33: * @return ICellRenderer
34: */
35: private ILabelProvider createProvider(Element elem) {
36: ILabelProvider ret = null;
37: try {
38: ret = (ILabelProvider) Class.forName(
39: elem.getAttribute("provider")).newInstance();
40: } catch (InstantiationException e) {
41: e.printStackTrace();
42: } catch (IllegalAccessException e) {
43: e.printStackTrace();
44: } catch (ClassNotFoundException e) {
45: e.printStackTrace();
46: }
47: return ret;
48: }
49:
50: }
|