01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.components;
20:
21: import com.jeta.forms.gui.beans.JETABean;
22: import com.jeta.forms.gui.beans.JETABeanFactory;
23: import com.jeta.forms.gui.common.FormException;
24: import com.jeta.forms.gui.common.FormUtils;
25: import com.jeta.forms.gui.components.AbstractComponentFactory;
26: import com.jeta.forms.gui.components.ComponentSource;
27: import com.jeta.forms.gui.form.FormComponent;
28: import com.jeta.forms.gui.form.GridComponent;
29: import com.jeta.forms.gui.form.GridView;
30: import com.jeta.forms.gui.formmgr.FormManager;
31: import com.jeta.open.registry.JETARegistry;
32: import com.jeta.swingbuilder.gui.editor.DesignFormComponent;
33:
34: /**
35: * ComponentFactory for creating forms.
36: *
37: * @author Jeff Tassin
38: */
39: public abstract class FormComponentFactoryBase extends
40: AbstractComponentFactory {
41:
42: /**
43: * ctor
44: */
45: public FormComponentFactoryBase() {
46: }
47:
48: /**
49: * ctor
50: */
51: public FormComponentFactoryBase(ComponentSource compsrc) {
52: super (compsrc);
53: }
54:
55: /**
56: * Helper method for creating a composite component that has a GridView as a
57: * child.
58: */
59: public FormComponent create(ComponentSource compsrc,
60: String compName, GridView parentView, int cols, int rows,
61: boolean embedded) throws FormException {
62: JETABean jbean = JETABeanFactory.createBean(GridView.class
63: .getName(), compName, true, true);
64: GridView childview = (GridView) jbean.getDelegate();
65: childview.initialize(cols, rows);
66:
67: String id = FormUtils.createUID();
68: if (compName != null && compName.indexOf("top.parent") >= 0) {
69: id = "top.parent" + id;
70: } else if (embedded) {
71: id = "embedded." + id;
72: }
73:
74: FormComponent form = new DesignFormComponent(id, jbean,
75: parentView, embedded);
76: installHandlers(form);
77: FormManager fmgr = (FormManager) JETARegistry
78: .lookup(FormManager.COMPONENT_ID);
79: if (fmgr != null) {
80: fmgr.registerForm(form);
81: }
82: return form;
83: }
84:
85: /**
86: * ComponentFactory implementation
87: */
88: public abstract GridComponent createComponent(String compName,
89: GridView parentView) throws FormException;
90:
91: }
|