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 java.io.File;
22:
23: import com.jeta.forms.gui.common.FormException;
24: import com.jeta.forms.gui.components.ComponentSource;
25: import com.jeta.forms.gui.form.FormComponent;
26: import com.jeta.forms.gui.form.GridComponent;
27: import com.jeta.forms.gui.form.GridView;
28: import com.jeta.forms.gui.formmgr.FormManager;
29: import com.jeta.open.registry.JETARegistry;
30: import com.jeta.swingbuilder.gui.formmgr.FormManagerDesignUtils;
31:
32: /**
33: * ComponentFactory for creating linked forms.
34: *
35: * @author Jeff Tassin
36: */
37: public class LinkedFormComponentFactory extends
38: FormComponentFactoryBase {
39:
40: /**
41: * ctor
42: */
43: public LinkedFormComponentFactory() {
44: }
45:
46: /**
47: * ctor
48: */
49: public LinkedFormComponentFactory(ComponentSource compsrc) {
50: super (compsrc);
51: }
52:
53: /**
54: * Helper method for creating a composite component that has a GridView as a
55: * child.
56: */
57: public FormComponent create(ComponentSource compsrc,
58: String compName, GridView parentView) throws FormException {
59: File f = FormManagerDesignUtils.openLinkedFormFile();
60: if (f != null) {
61: FormManager fmgr = (FormManager) JETARegistry
62: .lookup(FormManager.COMPONENT_ID);
63: FormComponent fc = fmgr.openLinkedForm(f);
64: fmgr.activateForm(fc.getId());
65: return fc;
66: } else {
67: return null;
68: }
69: }
70:
71: public GridComponent createComponent(String compName,
72: GridView parentView) throws FormException {
73: return create(getComponentSource(), compName, parentView);
74: }
75:
76: }
|