objectivehtml.htmlwidget
Class HtmlTable

java.lang.Object
  |
  +--objectivehtml.oms.OMSObject
        |
        +--objectivehtml.htmlwidget.HtmlElement
              |
              +--objectivehtml.htmlwidget.HtmlWidget
                    |
                    +--objectivehtml.htmlwidget.HtmlContainerWidget
                          |
                          +--objectivehtml.htmlwidget.HtmlTable

public class HtmlTable
extends HtmlContainerWidget

This class represents a html table. i.e.

	<table>
		<tr><td></td></tr>
		<tr><td></td></tr>
	</table>
 

This object allows users to place text and other widgets into a tabular format. The table is always rectangular.

A table is made up of HtmlTableRow objects and HtmlTableCell objects. Each HtmlTableRow object represents one row of the table and each HtmlTableCell object represents one cell of the table. HtmlTableCell objects have the ability the span either vertically or horizontally over other table cells.

Table rows and table columns can be shown/hidden using the methods setRowVisible(int,boolean) and setColumnVisible(int,boolean).

The current implementation of HtmlTable only supports the simple table model. The complex table model which was introduced in HTML 4.0 is not supported. The main reasons for this is because most developers use the simple model and everything that can be done with the complex version can be emulated with the simple version.


Fields inherited from class objectivehtml.htmlwidget.HtmlContainerWidget
m_alChildrenWidgets, m_bAutoEscape, m_sText
 
Fields inherited from class objectivehtml.htmlwidget.HtmlWidget
m_bDestroyed, m_bVisible, m_objHtmlForm, m_objParentWidget
 
Fields inherited from class objectivehtml.htmlwidget.HtmlElement
m_hmAttributes, m_sEndTag, m_sQuoteType, m_sStartTag
 
Constructor Summary
HtmlTable(HtmlContainerWidget objParent)
          Constructs an instance of HtmlTable with 1 row and 1 column.
HtmlTable(HtmlContainerWidget objParent, int nRows, int nColumns)
          Constructs an instance of HtmlTable with nRows rows and nColumns columns.
 
Method Summary
 HtmlTableRow appendTableRow(boolean bCloneLastRow)
          Adds a new row to this table.
 java.lang.String getAlign()
          Returns the alignment style of this object.
 java.lang.String getBgColor()
          Returns the background color of this object.
 java.lang.String getBorder()
          Returns the border of this object.
 java.lang.String getCaptionText()
          Returns the caption text for this table object.
 java.lang.String getCellPadding()
          Returns the cell padding of this object.
 java.lang.String getCellSpacing()
          Returns the cell spacing of this object.
 int getColumns()
          Returns the number of table columns.
 HtmlTableCaption getHtmlTableCaption()
          Returns a reference to the html table caption object.
 int getRows()
          Returns the number of table rows.
 HtmlTableCell getTableCell(int nRow, int nColumn)
          Returns the HtmlTableCell object for the specified table cell.
 HtmlTableRow getTableRow(int nRow)
          Returns the HtmlTableRow object for the specified table row.
 java.lang.String getWidth()
          Returns the width of this object.
 boolean isColumnVisible(int nColumn)
          Returns if a table column is visible or hidden.
 boolean isRowVisible(int nRow)
          Returns if a table row is visible or hidden.
protected  void isValidChildWidget(HtmlWidget objHtmlWidget)
          Overrides the default version, so that only HtmlTableRow objects can be added to this object.
 void setAlign(java.lang.String sAlign)
          Sets the alignment style of this object.
 void setBgColor(java.lang.String sBgColor)
          Sets the background color of this object.
 void setBorder(java.lang.String sBorder)
          Sets the border of this table.
 void setCaptionText(java.lang.String sCaptionText)
          Sets the text for the caption of the table.
 void setCellPadding(java.lang.String sCellPadding)
          Sets the cell padding of this table.
 void setCellSpacing(java.lang.String sCellSpacing)
          Sets the cell spacing of this table.
 void setColumns(int nTableColumns)
          Sets the number of table columns.
 void setColumnVisible(int nColumn, boolean bVisible)
          Sets a column to be either hidden or visible.
 void setRows(int nTableRows)
          Sets the number of table rows.
 void setRowVisible(int nRow, boolean bVisible)
          Sets a table row to be either hidden or visible.
 void setVisible(boolean bVisible)
          Sets the visibility of this object.
 void setWidth(java.lang.String sWidth)
          Sets the width of this object.
 void swapHtmlWidgets(int nFirstRow, int nSecondRow)
          Swaps the position of the 2 table rows.
protected  void updateVisibility()
          Updates the visible flag of all the widgets in the table.
 
Methods inherited from class objectivehtml.htmlwidget.HtmlContainerWidget
addHtmlWidget, appendChild, destroy, generateUpdateOrder, getChildrenCount, getChildrenWidgets, getChildWidget, getText, indexOfChildWidget, insertChild, insertHtmlWidget, isAutoEscape, isChildWidget, printHtml, printHtml, removeHtmlWidget, setAttribute, setAutoEscape, setBooleanAttribute, setText
 
Methods inherited from class objectivehtml.htmlwidget.HtmlWidget
changeParent, changeParent, getClassAttribute, getHtmlForm, getID, getOnClick, getOnDblClick, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getParent, getStyle, isDestroyed, isVisible, setClassAttribute, setID, setOnClick, setOnDblClick, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setStyle
 
Methods inherited from class objectivehtml.htmlwidget.HtmlElement
genEndTag, genStartTag, genStartTag, getAttribute, getAttributes, getBooleanAttribute, getQuoteType, printHtml, printHtml, printHtml, printHtml, printHtml, printHtml, setAttribute, setBooleanAttribute, setQuoteType, toString, toString
 
Methods inherited from class objectivehtml.oms.OMSObject
compareClasses, connect, disconnect, emit, isAlive, setAlive, signal, slot, slot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HtmlTable

public HtmlTable(HtmlContainerWidget objParent)
          throws InvalidParentWidgetException,
                 InvalidChildWidgetException
Constructs an instance of HtmlTable with 1 row and 1 column.
Parameters:
objParent - the parent object of this table
Throws:
InvalidParentWidgetException - if the specified parent widget is not valid
InvalidChildWidgetException - if the parent widget does not accept this widget as a child

HtmlTable

public HtmlTable(HtmlContainerWidget objParent,
                 int nRows,
                 int nColumns)
          throws InvalidParentWidgetException,
                 InvalidChildWidgetException
Constructs an instance of HtmlTable with nRows rows and nColumns columns.
Parameters:
objParent - the parent object of this table
nRows - the number of rows the table starts with
nColumns - the number of columns the table starts with
Throws:
InvalidParentWidgetException - if the specified parent widget is not valid
InvalidChildWidgetException - if the parent widget does not accept this widget as a child
Method Detail

getHtmlTableCaption

public HtmlTableCaption getHtmlTableCaption()
Returns a reference to the html table caption object.
Returns:
a reference to the table caption object
See Also:
setCaptionText(String)

setCaptionText

public void setCaptionText(java.lang.String sCaptionText)
Sets the text for the caption of the table. To clear the text specify a null reference. When no caption is set (null) then the caption tag will not be drawn by the printHtml() methods.
Parameters:
sCaptionText - the caption text
See Also:
getCaptionText(), getHtmlTableCaption()

getCaptionText

public java.lang.String getCaptionText()
Returns the caption text for this table object. If no caption is set then null is returned.
Returns:
the caption text
See Also:
setCaptionText(String), getHtmlTableCaption()

setVisible

public void setVisible(boolean bVisible)
Sets the visibility of this object. Overrides protected method to be public.
Overrides:
setVisible in class HtmlContainerWidget
Parameters:
bVisible - true if visible, false if invisible

getAlign

public java.lang.String getAlign()
Returns the alignment style of this object.
Returns:
the alignment style of this object
See Also:
setAlign(String)

setAlign

public void setAlign(java.lang.String sAlign)

Sets the alignment style of this object. Suitable values are "left", "center" and "right".

The html attribute it sets is "align".

If null is specified the attribute is cleared.

Parameters:
sAlign - the alignment style for this widget, if null is specified then this attribute will be cleared
See Also:
getAlign()

getBgColor

public java.lang.String getBgColor()
Returns the background color of this object.
Returns:
the background color of this object
See Also:
setBgColor(String)

setBgColor

public void setBgColor(java.lang.String sBgColor)

Sets the background color of this object. There 16 preset values "black", "silver", "gray", "white", "maroon", "red", "purple", "fushcia", "green", "lime", "olive", "yellow", "navy", "blue", "teal" and "navy". For all other colors you can specify the color in the format SRGB, i.e. #RRGGBB.

The html attribute it sets is "bgcolor".

If null is specified the attribute is cleared.

Parameters:
sBgColor - the background color for this widget, if null is specified then this attribute will be cleared
See Also:
getBgColor()

getWidth

public java.lang.String getWidth()
Returns the width of this object.
Returns:
the width of this object
See Also:
setWidth(String)

setWidth

public void setWidth(java.lang.String sWidth)

Sets the width of this object. There are 2 formats that can be used. The first is to give a precise pixel value, e.g. "400", meaning the object will attempt to be 400 pixels wide. The second is to give a percentage, this means the object will attempt to occupy that percentage of the available space to it. e.g. "80%", meaning the object will attempt to occupy 80 percent of the width space that is available to it.

The html attribute it sets is "width".

If null is specified the attribute is cleared.

Parameters:
sWidth - the width size for this widget, if null is specified then this attribute will be cleared
See Also:
getWidth()

getBorder

public java.lang.String getBorder()
Returns the border of this object.
Returns:
the border of this object
See Also:
setBorder(String)

setBorder

public void setBorder(java.lang.String sBorder)

Sets the border of this table. The border size is specified in pixels.

The html attribute it sets is "border".

If null is specified the attribute is cleared.

Parameters:
sBorder - the border size for this widget, if null is specified then this attribute will be cleared
See Also:
getBorder()

getCellPadding

public java.lang.String getCellPadding()
Returns the cell padding of this object.
Returns:
the cell padding of this object
See Also:
setCellPadding(String)

setCellPadding

public void setCellPadding(java.lang.String sCellPadding)

Sets the cell padding of this table. The cell padding size is specified in pixels. Cell padding is the space between the outermost widgets inside a table cell and the border of the table cell.

The html attribute it sets is "cellpadding".

If null is specified the attribute is cleared.

Parameters:
sCellPadding - the cell padding size for this widget, if null is specified then this attribute will be cleared
See Also:
getCellPadding()

getCellSpacing

public java.lang.String getCellSpacing()
Returns the cell spacing of this object.
Returns:
the cell spacing of this object
See Also:
setCellSpacing(String)

setCellSpacing

public void setCellSpacing(java.lang.String sCellSpacing)

Sets the cell spacing of this table. The cell spacing size is specified in pixels. Cell spacing is the space between the table cells.

The html attribute it sets is "cellspacing".

If null is specified the attribute is cleared.

Parameters:
sCellSpacing - the cell spacing size for this widget, if null is specified then this attribute will be cleared
See Also:
getCellSpacing()

appendTableRow

public HtmlTableRow appendTableRow(boolean bCloneLastRow)

Adds a new row to this table. If bCloneLastRow is specified to be true then the new row will have all the properties of the last row, otherwise the new row will have no default properties.

Parameters:
bCloneLastRow - indicates whether the new row will clone the properties of the last row
Returns:
the HtmlTableRow created

setRows

public void setRows(int nTableRows)

Sets the number of table rows.

If nTableRows is greater than the current number of rows then new table rows and table cells are created and appended to the end.

If nTableRows is less than the current number of rows then the table rows and table cells (starting from the end) are deleted. All widgets contained in the table cells will also be destroyed.

Parameters:
nTableRows - the new number of table rows
See Also:
getRows(), setColumns(int)

getRows

public int getRows()
Returns the number of table rows.
Returns:
the number of the table rows
See Also:
setRows(int)

setColumns

public void setColumns(int nTableColumns)

Sets the number of table columns.

If nTableColumns is greater than the current number of columns then new table cells are created and appended to the end.

If nTableColumns is less than the current number of columns then the table cells (starting from the end) are deleted. All widgets contained in the table cells will also be destroyed.

Parameters:
nTableColumns - the new number of table columns
See Also:
getColumns(), setRows(int)

getColumns

public int getColumns()
Returns the number of table columns.
Returns:
the number of the table columns
See Also:
setColumns(int)

getTableRow

public HtmlTableRow getTableRow(int nRow)
Returns the HtmlTableRow object for the specified table row.
Parameters:
nRow - the row index
Returns:
the HtmlTableRow object at the specified row index nRow

getTableCell

public HtmlTableCell getTableCell(int nRow,
                                  int nColumn)
Returns the HtmlTableCell object for the specified table cell.
Parameters:
the - row index
the - column index
Returns:
the HtmlTableCell object at the specified position (nRow, nColumn)

setRowVisible

public void setRowVisible(int nRow,
                          boolean bVisible)
Sets a table row to be either hidden or visible. If the row is set to invisible then all the objects contained in the HtmlTableRow object will also become invisible.
Parameters:
nRow - the row index
bVisible - true if the row is to visible, false otherwise
See Also:
isRowVisible(int), setColumnVisible(int, boolean), updateVisibility()

isRowVisible

public boolean isRowVisible(int nRow)
Returns if a table row is visible or hidden.
Returns:
true if visible, false otherwise
See Also:
setRowVisible(int, boolean)

setColumnVisible

public void setColumnVisible(int nColumn,
                             boolean bVisible)
Sets a column to be either hidden or visible. If the column is set to invisible then all the objects contained in the associated HtmlTableCell objects will also become invisible.
Parameters:
nColumn - the column index
bVisible - true if the column is to visible, false otherwise
See Also:
isColumnVisible(int), setRowVisible(int, boolean), updateVisibility()

isColumnVisible

public boolean isColumnVisible(int nColumn)
Returns if a table column is visible or hidden.
Returns:
true if visible, false otherwise
See Also:
setColumnVisible(int, boolean)

swapHtmlWidgets

public void swapHtmlWidgets(int nFirstRow,
                            int nSecondRow)

Swaps the position of the 2 table rows. Moves the table row at position nFirstRow to nSecondRow, and moves the table row at position nSecondRow to nFirstRow.

Overrides the default implementation. When rows are swapped the visibility is applied to the rows accordingly.

Overrides:
swapHtmlWidgets in class HtmlContainerWidget
Parameters:
nFirstRow - the first row
nSecondRow - the second row
See Also:
updateVisibility()

updateVisibility

protected void updateVisibility()
Updates the visible flag of all the widgets in the table. All hide/show methods will call this method to update the visibility of the affected widgets.

isValidChildWidget

protected void isValidChildWidget(HtmlWidget objHtmlWidget)
                           throws InvalidChildWidgetException
Overrides the default version, so that only HtmlTableRow objects can be added to this object.
Overrides:
isValidChildWidget in class HtmlContainerWidget
Parameters:
objHtmlWidget - the widget to test
Throws:
InvalidChildWidgetException - if the widget is not a HtmlTableRow object