com.arsdigita.bebop
Class ColumnPanel

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BlockStylable
                  extended bycom.arsdigita.bebop.SimpleContainer
                      extended bycom.arsdigita.bebop.ColumnPanel
All Implemented Interfaces:
Cloneable, Component, Container, Lockable

public class ColumnPanel
extends SimpleContainer

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 ColumnPanel 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 ColumnPanel 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 ColumnPanel of the Form. At the same time, tell the ColumnPanel used to lay out the FormSection that it is to be inserted into another panel.

The following pseudo-code illustrates the example. (It assumes that Form and FormSection are decorators of the ColumnPanel.)


   Form form = new Form(new ColumnPanel(2));
   FormSection sec = new FormSection(new ColumnPanel(2, true));

   sec.add(new Label("Basic Item Metadata"), ColumnPanel.FULL_WIDTH);
   sec.add(new Label("Title:"), ColumnPanel.RIGHT);
   sec.add(new Text("title"));

   form.add(sec, ColumnPanel.INSERT);
 

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/ColumnPanel.java#11 $
Author:
David Lutterkort

Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.BlockStylable
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
ColumnPanel(int nCols)
          Creates a table panel with the specified number of columns.
ColumnPanel(int nCols, boolean inserted)
          Creates a table panel with the specified number of columns that will be printed as a direct child of a ColumnPanel with the same number of columns.
 
Method Summary
 void add(Component c, int constraints)
          Adds a component, specifying its constraints.
 void generateXML(PageState state, Element parent)
          Adds child components as a subtree under table-style nodes.
 int getNumCols()
          Returns the number of columns for this ColumnPanel
 boolean isInserted()
          Determines whether this panel is to be inserted into another panel.
 void setBorder(boolean b)
           
 void setBorderColor(String c)
           
 void setBorderWidth(String w)
           
 void setColumnWidth(int col, String width)
           
 void setConstraint(Component c, int constraints)
          Sets the constraint for one child component.
 void setInserted(boolean inserted)
          Sets whether this panel will be printed inside a ColumnPanel with the same number of columns.
 void setPadBorder(boolean border)
           
 void setPadCellPadding(String padding)
           
 void setPadColor(String c)
           
 void setPadFrameWidth(String w)
           
 void setWidth(String w)
           
 
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.BlockStylable
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
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 class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.Component
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, register, respond, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked, lock
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

ColumnPanel

public ColumnPanel(int nCols)
Creates a table panel with the specified number of columns.

Parameters:
nCols - number of columns in the panel

ColumnPanel

public ColumnPanel(int nCols,
                   boolean inserted)
Creates a table panel with the specified number of columns that will be printed as a direct child of a ColumnPanel with the same number of columns.

Parameters:
nCols - number of columns in the panel
inserted - true if this panel is to be printed as a direct child of a ColumnPanel with the same number of columns
See Also:
setInserted(boolean)
Method Detail

add

public void add(Component c,
                int constraints)
Adds a component, specifying its constraints.

Specified by:
add in interface Container
Overrides:
add in class SimpleContainer
Parameters:
c - the component to add
constraints - the constraints for this component

setInserted

public void setInserted(boolean inserted)
Sets whether this panel will be printed inside a ColumnPanel with the same number of columns. If inserted is true, no <table> tags will be produced to enclose the child components.

Parameters:
inserted - true if this panel is to be printed inside a ColumnPanel with the same number of columns

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)

getNumCols

public final int getNumCols()
Returns the number of columns for this ColumnPanel

Returns:
the number of columns

generateXML

public void generateXML(PageState state,
                        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:pad>
   [<bebop:padFrame>]
    [<bebop:border>]
      <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:border>]
   [</bebop:padFrame>]
 </bebop:boxPanel>

Specified by:
generateXML in interface Component
Overrides:
generateXML in class SimpleContainer
Parameters:
state - the current page state
parent - the parent element for these child components
See Also:
SimpleContainer.setTag(String), SimpleContainer.setNamespace(String)

setBorderColor

public void setBorderColor(String c)

setBorderWidth

public void setBorderWidth(String w)

setColumnWidth

public void setColumnWidth(int col,
                           String width)

setBorder

public void setBorder(boolean b)

setPadColor

public void setPadColor(String c)

setWidth

public void setWidth(String w)

setPadFrameWidth

public void setPadFrameWidth(String w)

setPadBorder

public void setPadBorder(boolean border)

setPadCellPadding

public void setPadCellPadding(String padding)

setConstraint

public void setConstraint(Component c,
                          int constraints)
Sets the constraint for one child component.

Parameters:
c - the child component
constraints - the constraints to add


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC