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.common.FormException;
22: import com.jeta.forms.gui.components.ComponentSource;
23: import com.jeta.forms.gui.form.FormComponent;
24: import com.jeta.forms.gui.form.GridComponent;
25: import com.jeta.forms.gui.form.GridView;
26: import com.jeta.open.gui.framework.JETADialog;
27: import com.jeta.open.gui.utils.JETAToolbox;
28: import com.jeta.open.i18n.I18N;
29:
30: /**
31: * ComponentFactory for creating embedded forms.
32: *
33: * @author Jeff Tassin
34: */
35: public class EmbeddedFormComponentFactory extends
36: FormComponentFactoryBase {
37:
38: /**
39: * ctor
40: */
41: public EmbeddedFormComponentFactory() {
42: }
43:
44: /**
45: * ctor
46: */
47: public EmbeddedFormComponentFactory(ComponentSource compsrc) {
48: super (compsrc);
49: }
50:
51: /**
52: * Helper method for creating a composite component that has a GridView as a
53: * child.
54: */
55: public FormComponent create(ComponentSource compsrc,
56: String compName, GridView parentView) throws FormException {
57: /**
58: * Shows a dialog that prompts the user to enter the number of columns
59: * and rows for the new view.
60: */
61: GridSizePanel view = new GridSizePanel();
62: JETADialog dlg = (JETADialog) JETAToolbox.createDialog(
63: JETADialog.class, parentView, true);
64: dlg.setTitle(I18N.getLocalizedMessage("Grid Parameters"));
65: dlg.addValidator(view, view);
66: dlg.setPrimaryPanel(view);
67: dlg.setSize(dlg.getPreferredSize());
68: dlg.showCenter();
69: if (dlg.isOk()) {
70: FormComponent fc = create(compsrc, compName, parentView,
71: view.getColumns(), view.getRows(), true);
72: GridView.fillCells(fc.getChildView(), compsrc);
73: return fc;
74: } else {
75: return null;
76: }
77: }
78:
79: public GridComponent createComponent(String compName,
80: GridView parentView) throws FormException {
81: return create(getComponentSource(), compName, parentView);
82: }
83:
84: }
|