01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.widgets.form;
09:
10: import com.google.gwt.user.client.ui.Widget;
11: import com.gwtext.client.widgets.Panel;
12: import com.gwtext.client.widgets.layout.ColumnLayout;
13: import com.gwtext.client.widgets.layout.ColumnLayoutData;
14: import com.gwtext.client.widgets.layout.FormLayout;
15:
16: /**
17: * This is a helper class that allows you to add multiple fields / widgets to a single row in a Form.
18: */
19: public class MultiFieldPanel extends Panel {
20:
21: /**
22: * Create a new MultiFieldPanel.
23: */
24: public MultiFieldPanel() {
25: setBorder(true);
26: setLayout(new ColumnLayout());
27: }
28:
29: /**
30: * Add a Field with the specified width to the row.
31: *
32: * @param field the field
33: * @param width the width to allocate to the field.
34: */
35: public void addToRow(Field field, int width) {
36: Panel panel = new Panel();
37: panel.setBorder(false);
38: panel.setLayout(new FormLayout());
39: panel.setWidth(width);
40: panel.add(field);
41: add(panel);
42: }
43:
44: /**
45: * Add a Field to the row.
46: *
47: * @param field the field to add
48: * @param columnLayoutData the column layout data
49: * @see com.gwtext.client.widgets.layout.ColumnLayout
50: */
51: public void addToRow(Field field, ColumnLayoutData columnLayoutData) {
52: Panel panel = new Panel();
53: panel.setBorder(false);
54: panel.setLayout(new FormLayout());
55: panel.add(field);
56: add(panel, columnLayoutData);
57: }
58:
59: /**
60: * Add a Widget with the specified width to the row.
61: *
62: * @param field the field to add
63: * @param width the field width
64: * @see com.gwtext.client.widgets.layout.ColumnLayout
65: */
66: public void addToRow(Widget field, int width) {
67: Panel panel = new Panel();
68: panel.setBorder(false);
69: panel.setWidth(width);
70: panel.add(field);
71: add(panel);
72: }
73:
74: /**
75: * Add a Widget to the row.
76: *
77: * @param field the field to add
78: * @param columnLayoutData the column layout data
79: * @see com.gwtext.client.widgets.layout.ColumnLayout
80: */
81: public void addToRow(Widget field, ColumnLayoutData columnLayoutData) {
82: Panel panel = new Panel();
83: panel.setBorder(false);
84: panel.add(field);
85: add(panel, columnLayoutData);
86: }
87: }
|