com.google.gwt.user.client.ui
Class HTMLTable

java.lang.Object
  extended bycom.google.gwt.user.client.ui.UIObject
      extended bycom.google.gwt.user.client.ui.Widget
          extended bycom.google.gwt.user.client.ui.Panel
              extended bycom.google.gwt.user.client.ui.HTMLTable
All Implemented Interfaces:
EventListener, HasWidgets, SourcesTableEvents
Direct Known Subclasses:
FlexTable, Grid

public abstract class HTMLTable
extends Panel
implements SourcesTableEvents

HTMLTable contains the common table algorithms for Grid and FlexTable.


Nested Class Summary
 class HTMLTable.CellFormatter
          This class contains methods used to format a table's cells.
 class HTMLTable.RowFormatter
          This class contains methods used to format a table's rows.
 
Field Summary
 
Fields inherited from class java.lang.Object
typeId, typeName
 
Constructor Summary
HTMLTable()
           
 
Method Summary
 boolean add(Widget w)
          This method is not implemented, as widgets must be added to specific cells in the table.
 void addTableListener(TableListener listener)
          Adds a listener interface to receive click events.
protected  void checkCellBounds(int row, int column)
          Bounds checks that the cell exists at the specified location
protected  void checkRowBounds(int row)
          Checks that the row is within the correct bounds.
 void clear()
          Removes all widgets from this table, but does not remove other HTML or text contents of cells.
 boolean clearCell(int row, int column)
          Clears the given row and column.
protected  String computeKey(int row, int column)
          Gets the key associated with the cell.
protected  Element createCell()
          Creates a new cell.
protected  Element getBodyElement()
          Gets the table's TBODY element.
abstract  int getCellCount(int row)
          Gets the number of cells in a given row.
 HTMLTable.CellFormatter getCellFormatter()
          Gets the HTMLTable.CellFormatter associated with this table.
 int getCellPadding()
          Gets the amount of padding that is added around all cells.
 int getCellSpacing()
          Gets the amount of spacing that is added around all cells.
protected  int getDOMCellCount(int row)
          Directly ask the underlying DOM what the cell count on the given row is.
protected  int getDOMRowCount()
          Directly ask the underlying DOM what the row count is.
 String getHTML(int row, int column)
          Gets the HTML contents of the specified cell.
abstract  int getRowCount()
          Gets the number of rows present in this table.
 HTMLTable.RowFormatter getRowFormatter()
          Gets the RowFormatter associated with this table.
 String getText(int row, int column)
          Gets the text within the specified cell.
 Widget getWidget(int row, int column)
          Gets the widget in the specified cell.
protected  void insertCell(int row, int column)
          Inserts a new cell into the specified row.
protected  void insertCells(int row, int column, int count)
          Inserts a number of cells before the specified cell.
protected  int insertRow(int beforeRow)
          Inserts a new row into the table.
protected  boolean internalClearCell(int row, int column, Element td)
          Does actual clearing, used by clearCell and cleanCell.
 boolean isCellPresent(int row, int column)
          Determines whether the specified cell exists.
 Iterator iterator()
          Gets an iterator for the contained widgets.
 void onBrowserEvent(Event event)
          Fired whenever a browser event is received.
protected abstract  void prepareCell(int row, int column)
          Subclasses must implement this method.
protected abstract  void prepareRow(int row)
          Subclasses must implement this method.
 boolean remove(Widget widget)
          Removes a widget from the panel.
protected  void removeCell(int row, int column)
          Removes the specified cell from the table.
protected  void removeRow(int row)
          Removes the specified row from the table.
 void removeTableListener(TableListener listener)
          Removes a previously added listener interface.
 void setBorderWidth(int width)
          Sets the width of the table's border.
protected  void setCellFormatter(HTMLTable.CellFormatter cellFormatter)
          Sets the table's CellFormatter.
 void setCellPadding(int padding)
          Sets the amount of padding to be added around all cells.
 void setCellSpacing(int spacing)
          Sets the amount of spacing to be added around all cells.
 void setHTML(int row, int column, String html)
          Sets the HTML contents of the specified cell.
protected  void setRowFormatter(HTMLTable.RowFormatter rowFormatter)
          Sets the table's RowFormatter.
 void setText(int row, int column, String text)
          Sets the text within the specified cell.
 void setWidget(int row, int column, Widget widget)
          Sets the widget within the specified cell.
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
adopt, disown, onAttach, onDetach
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onLoad
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, finalize, hashCode
 

Constructor Detail

HTMLTable

public HTMLTable()
Method Detail

add

public boolean add(Widget w)
This method is not implemented, as widgets must be added to specific cells in the table.

Specified by:
add in class Panel
Parameters:
w - the child widget to be added
Returns:
true on success (some panels place restrictions on how children may be added or inserted)

addTableListener

public void addTableListener(TableListener listener)
Description copied from interface: SourcesTableEvents
Adds a listener interface to receive click events.

Specified by:
addTableListener in interface SourcesTableEvents
Parameters:
listener - the listener interface to add

clear

public void clear()
Removes all widgets from this table, but does not remove other HTML or text contents of cells.

Specified by:
clear in class Panel

clearCell

public boolean clearCell(int row,
                         int column)
Clears the given row and column. If it contains a Widget, it will be removed from the table. If not, its contents will simply be cleared.

Parameters:
row - the widget's column
column - the widget's column
Returns:
true if a widget was removed
Throws:
IndexOutOfBoundsException

getCellCount

public abstract int getCellCount(int row)
Gets the number of cells in a given row.

Parameters:
row - the row whose cells are to be counted
Returns:
the number of cells present in the row

getCellFormatter

public HTMLTable.CellFormatter getCellFormatter()
Gets the HTMLTable.CellFormatter associated with this table.

Returns:
this table's cell formatter

getCellPadding

public int getCellPadding()
Gets the amount of padding that is added around all cells.

Returns:
the cell padding, in pixels

getCellSpacing

public int getCellSpacing()
Gets the amount of spacing that is added around all cells.

Returns:
the cell spacing, in pixels

getHTML

public String getHTML(int row,
                      int column)
Gets the HTML contents of the specified cell.

Parameters:
row - the cell's row
column - the cell's column
Returns:
the cell's HTML contents
Throws:
IndexOutOfBoundsException

getRowCount

public abstract int getRowCount()
Gets the number of rows present in this table.

Returns:
the table's row count

getRowFormatter

public HTMLTable.RowFormatter getRowFormatter()
Gets the RowFormatter associated with this table.

Returns:
the table's row formatter

getText

public String getText(int row,
                      int column)
Gets the text within the specified cell.

Parameters:
row - the cell's row
column - the cell's column
Returns:
the cell's text contents
Throws:
IndexOutOfBoundsException

getWidget

public Widget getWidget(int row,
                        int column)
Gets the widget in the specified cell.

Parameters:
row - the cell's row
column - the cell's column
Returns:
the widget in the specified cell, or null if none is present
Throws:
IndexOutOfBoundsException

isCellPresent

public boolean isCellPresent(int row,
                             int column)
Determines whether the specified cell exists.

Parameters:
row - the cell's row
column - the cell's column
Returns:
true if the specified cell exists

iterator

public Iterator iterator()
Description copied from interface: HasWidgets
Gets an iterator for the contained widgets.

Specified by:
iterator in interface HasWidgets

onBrowserEvent

public void onBrowserEvent(Event event)
Description copied from interface: EventListener
Fired whenever a browser event is received.

Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Widget

remove

public boolean remove(Widget widget)
Description copied from class: Panel
Removes a widget from the panel.

Specified by:
remove in class Panel
Parameters:
widget - the widget to be removed
Returns:
true if the widget was present

removeTableListener

public void removeTableListener(TableListener listener)
Description copied from interface: SourcesTableEvents
Removes a previously added listener interface.

Specified by:
removeTableListener in interface SourcesTableEvents
Parameters:
listener - the listener interface to remove

setBorderWidth

public void setBorderWidth(int width)
Sets the width of the table's border. This border is displayed around all cells in the table.

Parameters:
width - the width of the border, in pixels

setCellPadding

public void setCellPadding(int padding)
Sets the amount of padding to be added around all cells.

Parameters:
padding - the cell padding, in pixels

setCellSpacing

public void setCellSpacing(int spacing)
Sets the amount of spacing to be added around all cells.

Returns:
the cell spacing, in pixels

setHTML

public void setHTML(int row,
                    int column,
                    String html)
Sets the HTML contents of the specified cell.

Parameters:
row - the cell's row
column - the cell's column
html - the cell's HTML contents
Throws:
IndexOutOfBoundsException

setText

public void setText(int row,
                    int column,
                    String text)
Sets the text within the specified cell.

Parameters:
row - the cell's row
column - cell's column
text - the cell's text contents
Throws:
IndexOutOfBoundsException

setWidget

public void setWidget(int row,
                      int column,
                      Widget widget)
Sets the widget within the specified cell.

Inherited implementations may either throw IndexOutOfBounds exception if the cell does not exist, or allocate a new cell to store the content

Parameters:
widget - The widget to be added
row - the cell's row
column - the cell's column
Throws:
IndexOutOfBoundsException

checkCellBounds

protected void checkCellBounds(int row,
                               int column)
Bounds checks that the cell exists at the specified location

Parameters:
row - cell's row
column - cell's column
Throws:
IndexOutOfBoundsException

checkRowBounds

protected void checkRowBounds(int row)
Checks that the row is within the correct bounds.

Parameters:
row - row index to check
Throws:
IndexOutOfBoundsException

computeKey

protected String computeKey(int row,
                            int column)
Gets the key associated with the cell. This key is used within the widget map.

Parameters:
row - the cell's row
column - the cell's column
Returns:
the associated key

createCell

protected Element createCell()
Creates a new cell. Override this method if the cell should have initial contents.

Returns:
the newly created TD

getBodyElement

protected Element getBodyElement()
Gets the table's TBODY element.

Returns:
the TBODY element

getDOMCellCount

protected int getDOMCellCount(int row)
Directly ask the underlying DOM what the cell count on the given row is.

Parameters:
row - the row
Returns:
number of columns in the row

getDOMRowCount

protected int getDOMRowCount()
Directly ask the underlying DOM what the row count is.

Returns:
Returns the number of rows in the table

insertCell

protected void insertCell(int row,
                          int column)
Inserts a new cell into the specified row.

Parameters:
row - the row into which the new cell will be inserted
column - the column before which the cell will be inserted
Throws:
IndexOutOfBoundsException

insertCells

protected void insertCells(int row,
                           int column,
                           int count)
Inserts a number of cells before the specified cell.

Parameters:
row - the row into which the new cells will be inserted
column - the column before which the new cells will be inserted
count - number of cells to be inserted
Throws:
IndexOutOfBoundsException

insertRow

protected int insertRow(int beforeRow)
Inserts a new row into the table.

Parameters:
beforeRow - the index before which the new row will be inserted
Returns:
the index of the newly-created row
Throws:
IndexOutOfBoundsException

internalClearCell

protected boolean internalClearCell(int row,
                                    int column,
                                    Element td)
Does actual clearing, used by clearCell and cleanCell. All HTMLTable methods should use internalClearCell rather than clearCell, as clearCell may be overridden in subclasses to format an empty cell.


prepareCell

protected abstract void prepareCell(int row,
                                    int column)
Subclasses must implement this method. It allows them to decide what to do just before a cell is accessed. If the cell already exists, this method must do nothing. Otherwise, a subclass must either ensure that the cell exists or throw an IndexOutOfBoundsException.

Parameters:
row - the cell's row
column - the cell's column

prepareRow

protected abstract void prepareRow(int row)
Subclasses must implement this method. It allows them to decide what to do just before a row is accessed. If the row already exists, this method must do nothing. Otherwise, a subclass must either ensure that the row exists or throw an IndexOutOfBoundsException.

Parameters:
row - the cell's row

removeCell

protected void removeCell(int row,
                          int column)
Removes the specified cell from the table.

Parameters:
row - the row of the cell to remove
column - the column of cell to remove
Throws:
IndexOutOfBoundsException

removeRow

protected void removeRow(int row)
Removes the specified row from the table.

Parameters:
row - the index of the row to be removed
Throws:
IndexOutOfBoundsException

setCellFormatter

protected void setCellFormatter(HTMLTable.CellFormatter cellFormatter)
Sets the table's CellFormatter.

Parameters:
cellFormatter - the table's cell formatter

setRowFormatter

protected void setRowFormatter(HTMLTable.RowFormatter rowFormatter)
Sets the table's RowFormatter.

Parameters:
rowFormatter - the table's row formatter


This javadoc distribution was not produced by Google. The official documentation is here.