com.arsdigita.bebop
Class GridPanel
java.lang.Object
com.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.TextStylable
com.arsdigita.bebop.BlockStylable
com.arsdigita.bebop.SimpleContainer
com.arsdigita.bebop.GridPanel
- All Implemented Interfaces:
- BebopConstants, Cloneable, Component, Container, Lockable
- public class GridPanel
- extends SimpleContainer
- implements BebopConstants
A container that prints its components in a table. Each child is
printed in its own table cell. The number of columns can be
specified in the constructor. The components are put into the table
in the order in which they were added to the GridPanel
by filling the table one row
at a time (filling each row from left to right), from the top of the table
to the bottom.
The position of the component within the cell can be influenced
with the following constraints.
| Horizontal alignment |
Use LEFT, CENTER, or
RIGHT. |
| Vertical alignment |
Use TOP, MIDDLE, or
BOTTOM. |
| Full width |
Use FULL_WIDTH to instruct the panel to put
the component in a row by itself, spanning the full width of the
table. |
| Inserting children |
Use INSERT to instruct the panel to
insert the corresponding component, assuming that it will also be
laid out by a ColumnPanel with the same number of
columns. |
Constraints can be combined by
ORing them together. For example, to print a component in a row of its
own, left-aligned, at the bottom of its cell, use the constraint
FULL_WIDTH | LEFT | BOTTOM.
Using the INSERT constraint fuses the current
GridPanel with the panel of the child to which the
constraint is applied. For example, consider a Form, that
is to have a 2-column format with labels in the left column
and widgets in the right column. If a FormSection is added to
the form, it should be included seamlessly into the parent
form. To do this, set the INSERT
constraint when the FormSection is added to the Form's GridPanel. At the same time, tell the
GridPanel used to lay out the FormSection
that it is is to be inserted into another panel.
The following
pseudo-code illustrates the example. (It assumes that Form and
FormSection are decorators of the GridPanel.)
Form form = new Form(new GridPanel(2));
FormSection sec = new FormSection(new GridPanel(2, true));
// "true" in the above constructor tells the GridPanel it is inserted.
sec.add(new Label("Basic Item Metadata"), GridPanel.FULL_WIDTH);
sec.add(new Label("Title:"), GridPanel.RIGHT);
sec.add(new Text("title"));
form.add(sec, GridPanel.INSERT);
- Version:
- $Id: //core-platform/dev/src/com/arsdigita/bebop/GridPanel.java#8 $
- Author:
- David Lutterkort, Stanislav Freidin, Justin Ross
- See Also:
BoxPanel,
SplitPanel
| Fields inherited from class com.arsdigita.bebop.BlockStylable |
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP |
| Fields inherited from interface com.arsdigita.bebop.util.BebopConstants |
BEBOP_BORDER, BEBOP_BOXPANEL, BEBOP_CELL, BEBOP_CHECKBOX, BEBOP_CHECKBOXGROUP, BEBOP_COLUMNPANEL, BEBOP_DATE, BEBOP_DATETIME, BEBOP_DHTMLEDITOR, BEBOP_FORMERRORS, BEBOP_FORMWIDGET, BEBOP_GRIDPANEL, BEBOP_LIST, BEBOP_MULTISELECT, BEBOP_OPTION, BEBOP_PAD, BEBOP_PADFRAME, BEBOP_PANELROW, BEBOP_PORTAL, BEBOP_PORTLET, BEBOP_RADIO, BEBOP_RADIOGROUP, BEBOP_SEG_BODY, BEBOP_SEG_HEADER, BEBOP_SEG_PANEL, BEBOP_SEGMENT, BEBOP_SELECT, BEBOP_TABLE, BEBOP_TABLEBODY, BEBOP_TABLEROW, BEBOP_TEXTAREA |
|
Constructor Summary |
GridPanel(int numColumns)
Creates a table panel with the specified number of columns. |
GridPanel(int numColumns,
boolean isInserted)
Creates a table panel with the specified number of columns and
indicates whether the panel is inserted. |
|
Method Summary |
void |
add(Component component,
int constraints)
Adds a component, specifying constraints. |
void |
generateXML(PageState pageState,
Element parent)
Adds child components as a subtree under table-style nodes. |
boolean |
isInserted()
Determines whether this panel is to be inserted into another panel. |
void |
setInserted(boolean isInserted)
Sets whether this panel will be printed inside a
GridPanel with the same number of columns. |
| Methods inherited from class com.arsdigita.bebop.SimpleContainer |
add, children, contains, generateChildrenXML, generateParent, get, getNamespace, getTag, indexOf, isEmpty, setNamespace, setTag, size |
| Methods inherited from class com.arsdigita.bebop.SimpleComponent |
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, register, respond, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
| Methods inherited from interface com.arsdigita.bebop.Component |
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, register, respond, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible |
versionId
public static final String versionId
- See Also:
- Constant Field Values
GridPanel
public GridPanel(int numColumns)
- Creates a table panel with the specified number of columns.
- Parameters:
numColumns - the number of columns in the panel
GridPanel
public GridPanel(int numColumns,
boolean isInserted)
- Creates a table panel with the specified number of columns and
indicates whether the panel is inserted.
- Parameters:
numColumns - the number of columns in the panelisInserted - true if this panel is to be
printed as a direct child of a GridPanel
with the same number of columns- See Also:
setInserted(boolean)
add
public void add(Component component,
int constraints)
- Adds a component, specifying constraints.
- Specified by:
add in interface Container- Overrides:
add in class SimpleContainer
- Parameters:
component - the component to addconstraints - the constraints for the component
setInserted
public void setInserted(boolean isInserted)
- Sets whether this panel will be printed inside a
GridPanel with the same number of columns. If
inserted is true, no <table> tags will be
produced to enclose the child components.
isInserted
public final boolean isInserted()
- Determines whether this panel is to be inserted into another panel.
- Returns:
true if this panel is to be inserted into another panel;
false otherwise.- See Also:
setInserted(boolean)
generateXML
public void generateXML(PageState pageState,
Element parent)
- Adds child components as a subtree under table-style nodes. If any of the
direct children are hidden form widgets, they are added directly to
parent rather than included in any of the
cell elements of the panel.
Generates a DOM fragment:
<bebop:gridPanel>
<bebop:panelRow>
<bebop:cell> ... cell contents </bebop:cell>
<bebop:cell> ... cell contents </bebop:cell>
...
</bebop:panelRow>
<bebop:panelRow>
<bebop:cell> ... cell contents </bebop:cell>
<bebop:cell> ... cell contents </bebop:cell>
...
</bebop:panelRow>
</bebop:gridPanel>
- Specified by:
generateXML in interface Component- Overrides:
generateXML in class SimpleContainer
- Parameters:
pageState - represents the current requestparent - the parent XML element- See Also:
SimpleContainer.setTag(String),
SimpleContainer.setNamespace(String)
Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC