com.google.gwt.widgetideas.table.client
Class FixedWidthGrid

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.widgetideas.table.client.overrides.HTMLTable
                  extended by com.google.gwt.widgetideas.table.client.overrides.Grid
                      extended by com.google.gwt.widgetideas.table.client.SelectionGrid
                          extended by com.google.gwt.widgetideas.table.client.SortableGrid
                              extended by com.google.gwt.widgetideas.table.client.FixedWidthGrid
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.SourcesTableEvents, SourceTableSelectionEvents

public class FixedWidthGrid
extends SortableGrid

A variation of the Grid that resizes columns using a fixed table width.


Nested Class Summary
 class FixedWidthGrid.FixedWidthGridCellFormatter
          This class contains methods used to format a table's cells.
 class FixedWidthGrid.FixedWidthGridColumnFormatter
          This class contains methods used to format a table's columns.
 class FixedWidthGrid.FixedWidthGridRowFormatter
          This class contains methods used to format a table's rows.
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.SortableGrid
SortableGrid.ColumnSorter, SortableGrid.ColumnSorterCallback
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.SelectionGrid
SelectionGrid.SelectionGridCellFormatter, SelectionGrid.SelectionGridRowFormatter, SelectionGrid.SelectionPolicy
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
HTMLTable.CellFormatter, HTMLTable.ColumnFormatter, HTMLTable.RowFormatter, HTMLTable.WidgetMapper
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
static int DEFAULT_COLUMN_WIDTH
          The default width of a column in pixels.
static int MIN_COLUMN_WIDTH
          The minimum width of any column.
 
Fields inherited from class com.google.gwt.widgetideas.table.client.overrides.Grid
numColumns, numRows
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
FixedWidthGrid()
          Constructor.
FixedWidthGrid(int rows, int columns)
          Constructs a FixedWidthGrid with the requested size.
 
Method Summary
 int autoFitColumnWidth(int column)
          Stretches or shrinks the column to automatically fit its data content.
 int getAutoFitColumnWidth(int column)
          Calculate the minimum required width to fit the contents of the column, but do not actually change the column size.
protected  com.google.gwt.user.client.Element getCellContainer(com.google.gwt.user.client.Element td)
          Get the container element from a cell.
 int getColumnWidth(int column)
          Return the column width for a given column index.
protected  int getDOMCellCount(int row)
          Directly ask the underlying DOM what the cell count on the given row is.
protected  com.google.gwt.user.client.Element getDOMGhostRow(HTMLTable table)
          Gets the new ghost element directly from the table.
protected  int getDOMRowCount()
          Directly ask the underlying DOM what the row count is.
protected  FixedWidthGrid.FixedWidthGridCellFormatter getFixedWidthGridCellFormatter()
          Explicitly gets the FixedWidthGrid.FixedWidthGridCellFormatter.
protected  FixedWidthGrid.FixedWidthGridRowFormatter getFixedWidthGridRowFormatter()
          Explicitly gets the FixedWidthGrid.FixedWidthGridRowFormatter.
protected  int getGhostColumnCount()
           
protected  com.google.gwt.user.client.Element getGhostRow()
           
protected  int getRowIndex(com.google.gwt.user.client.Element rowElem)
           
protected  com.google.gwt.user.client.Element insertCell(int row, int column)
          Inserts a new cell into the specified row.
 int insertRow(int beforeRow)
          Inserts a new row into the table.
protected  void prepareCell(int row, int column)
          Checks that a cell is a valid cell in the table.
protected  void prepareColumn(int column)
          Checks that the column index is valid.
protected  void prepareRow(int row)
          Checks that the row index is valid.
 void removeRow(int row)
          Removes the specified row from the table.
 void resizeColumns(int columns)
          Resizes the grid to the specified number of columns.
 void resizeRows(int rows)
          Resizes the grid to the specified number of rows.
 void setColumnWidth(int column, int width)
          Set the width of a column.
protected  void setGhostRow(com.google.gwt.user.client.Element ghostRow)
          Sets the ghost row variable.
protected  void updateGhostRow()
          Add or remove ghost cells when the table size changes.
 
Methods inherited from class com.google.gwt.widgetideas.table.client.SortableGrid
addSortableColumnsListener, fireColumnSorted, getColumnSorter, getColumnSorter, getColumnSortList, moveRowDown, moveRowUp, removeSortableColumnsListener, reverseRows, setColumnSorter, sortColumn, sortColumn, swapRows, swapRowsRaw
 
Methods inherited from class com.google.gwt.widgetideas.table.client.SelectionGrid
addTableSelectionListener, deselectRow, deselectRows, getSelectedRows, getSelectedRowsMap, getSelectionGridCellFormatter, getSelectionGridRowFormatter, getSelectionPolicy, hoverCell, isRowSelected, onBrowserEvent, removeTableSelectionListener, selectRow, selectRow, selectRow, setSelectionPolicy
 
Methods inherited from class com.google.gwt.widgetideas.table.client.overrides.Grid
createCell, getCellCount, getColumnCount, getRowCount, resize
 
Methods inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
addTableListener, checkCellBounds, checkRowBounds, cleanCell, clear, clearAll, clearCell, getBodyElement, getCellContainer, getCellFormatter, getCellPadding, getCellSpacing, getColumnFormatter, getDOMCellCount, getDOMRowCount, getEventTargetCell, getEventTargetRow, getHTML, getRowFormatter, getText, getWidget, getWidgetMap, insertCells, internalClearCell, isCellPresent, iterator, remove, removeCell, removeTableListener, setBodyElement, setBorderWidth, setCellFormatter, setCellPadding, setCellSpacing, setClearText, setColumnFormatter, setElement, setHTML, setRowFormatter, setText, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, adopt, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onAttach, onDetach, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_COLUMN_WIDTH

public static final int DEFAULT_COLUMN_WIDTH
The default width of a column in pixels.

See Also:
Constant Field Values

MIN_COLUMN_WIDTH

public static final int MIN_COLUMN_WIDTH
The minimum width of any column.

See Also:
Constant Field Values
Constructor Detail

FixedWidthGrid

public FixedWidthGrid()
Constructor.


FixedWidthGrid

public FixedWidthGrid(int rows,
                      int columns)
Constructs a FixedWidthGrid with the requested size.

Parameters:
rows - the number of rows
columns - the number of columns
Throws:
java.lang.IndexOutOfBoundsException
Method Detail

autoFitColumnWidth

public int autoFitColumnWidth(int column)
Stretches or shrinks the column to automatically fit its data content.

Parameters:
column - the column to fit
Returns:
the new column width
Throws:
java.lang.IndexOutOfBoundsException

getAutoFitColumnWidth

public int getAutoFitColumnWidth(int column)
Calculate the minimum required width to fit the contents of the column, but do not actually change the column size.

Parameters:
column - the column to fit
Returns:
the minimum column width
Throws:
java.lang.IndexOutOfBoundsException

getColumnWidth

public int getColumnWidth(int column)
Return the column width for a given column index. If a width has not been assigned, the default width is returned.

Parameters:
column - the column index
Returns:
the column width in pixels

insertRow

public int insertRow(int beforeRow)
Description copied from class: HTMLTable
Inserts a new row into the table.

Overrides:
insertRow in class SelectionGrid
Parameters:
beforeRow - the index before which the new row will be inserted
Returns:
the index of the newly-created row
See Also:
HTMLTable

removeRow

public void removeRow(int row)
Description copied from class: HTMLTable
Removes the specified row from the table.

Overrides:
removeRow in class SelectionGrid
Parameters:
row - the index of the row to be removed
See Also:
HTMLTable

resizeColumns

public void resizeColumns(int columns)
Description copied from class: Grid
Resizes the grid to the specified number of columns.

Overrides:
resizeColumns in class Grid
Parameters:
columns - the number of columns
See Also:
Grid

resizeRows

public void resizeRows(int rows)
Description copied from class: Grid
Resizes the grid to the specified number of rows.

Overrides:
resizeRows in class Grid
Parameters:
rows - the number of rows
See Also:
Grid

setColumnWidth

public void setColumnWidth(int column,
                           int width)
Set the width of a column.

Parameters:
column - the index of the column
width - the width in pixels
Throws:
java.lang.IndexOutOfBoundsException

getCellContainer

protected com.google.gwt.user.client.Element getCellContainer(com.google.gwt.user.client.Element td)
Get the container element from a cell. The container element is a span inside of the cell that actually holds the content.

Overrides:
getCellContainer in class HTMLTable
Parameters:
td - the cell element
Returns:
the container element

getDOMCellCount

protected int getDOMCellCount(int row)
Description copied from class: HTMLTable
Directly ask the underlying DOM what the cell count on the given row is.

Overrides:
getDOMCellCount in class HTMLTable
Parameters:
row - the row
Returns:
number of columns in the row
See Also:
HTMLTable

getDOMGhostRow

protected com.google.gwt.user.client.Element getDOMGhostRow(HTMLTable table)
Gets the new ghost element directly from the table.

Parameters:
table - the table
Returns:
the new ghost row

getDOMRowCount

protected int getDOMRowCount()
Description copied from class: HTMLTable
Directly ask the underlying DOM what the row count is.

Overrides:
getDOMRowCount in class HTMLTable
Returns:
Returns the number of rows in the table
See Also:
HTMLTable

getFixedWidthGridCellFormatter

protected FixedWidthGrid.FixedWidthGridCellFormatter getFixedWidthGridCellFormatter()
Explicitly gets the FixedWidthGrid.FixedWidthGridCellFormatter. The results of HTMLTable.getCellFormatter() may also be downcast to a FixedWidthGrid.FixedWidthGridCellFormatter.

Returns:
the FixedWidthGrid's cell formatter

getFixedWidthGridRowFormatter

protected FixedWidthGrid.FixedWidthGridRowFormatter getFixedWidthGridRowFormatter()
Explicitly gets the FixedWidthGrid.FixedWidthGridRowFormatter. The results of HTMLTable.getCellFormatter() may also be downcast to a FixedWidthGrid.FixedWidthGridRowFormatter.

Returns:
the FixedWidthGrid's cell formatter

getGhostColumnCount

protected int getGhostColumnCount()
Returns:
the number of columns in the ghost row

getGhostRow

protected com.google.gwt.user.client.Element getGhostRow()
Returns:
the ghost row element

getRowIndex

protected int getRowIndex(com.google.gwt.user.client.Element rowElem)
Overrides:
getRowIndex in class HTMLTable
Parameters:
rowElem - the row element
Returns:
the index of a row
See Also:
SelectionGrid

insertCell

protected com.google.gwt.user.client.Element insertCell(int row,
                                                        int column)
Description copied from class: HTMLTable
Inserts a new cell into the specified row.

Overrides:
insertCell in class HTMLTable
Parameters:
row - the row into which the new cell will be inserted
column - the column before which the cell will be inserted
Returns:
the new element
See Also:
HTMLTable

prepareCell

protected void prepareCell(int row,
                           int column)
Description copied from class: Grid
Checks that a cell is a valid cell in the table.

Overrides:
prepareCell in class Grid
Parameters:
row - the cell's row
column - the cell's column
See Also:
Grid

prepareColumn

protected void prepareColumn(int column)
Description copied from class: Grid
Checks that the column index is valid.

Overrides:
prepareColumn in class Grid
Parameters:
column - The column index to be checked
See Also:
Grid

prepareRow

protected void prepareRow(int row)
Description copied from class: Grid
Checks that the row index is valid.

Overrides:
prepareRow in class Grid
Parameters:
row - The row index to be checked
See Also:
Grid

setGhostRow

protected void setGhostRow(com.google.gwt.user.client.Element ghostRow)
Sets the ghost row variable. This does not change the underlying structure of the table.

Parameters:
ghostRow - the new ghost row

updateGhostRow

protected void updateGhostRow()
Add or remove ghost cells when the table size changes.