com.vaadin.client.ui.grid
Class Escalator.AbstractRowContainer

java.lang.Object
  extended by com.vaadin.client.ui.grid.Escalator.AbstractRowContainer
All Implemented Interfaces:
RowContainer
Enclosing class:
Escalator

protected abstract class Escalator.AbstractRowContainer
extends java.lang.Object
implements RowContainer


Field Summary
protected  double heightOfSection
          The height of the combined rows in the DOM.
protected  TableSectionElement root
          The table section element (<thead>, <tbody> or <tfoot>) the rows (i.e.
 
Fields inherited from interface com.vaadin.client.ui.grid.RowContainer
INITIAL_DEFAULT_ROW_HEIGHT
 
Constructor Summary
Escalator.AbstractRowContainer(TableSectionElement rowContainerElement)
           
 
Method Summary
protected  void assertArgumentsAreValidAndWithinRange(int index, int numberOfRows)
           
 void autodetectRowHeight()
           
protected  int calculateEstimatedTotalRowHeight()
          Returns the estimated height of all rows in the row container.
 int calculateMaxColWidth(int index)
          Iterates through all the cells in a column and returns the width of the widest element in this RowContainer.
 TableCellElement createCellElement(int height, int width)
          Create and setup an empty cell element.
 Cell getCell(Element element)
          Returns the cell object which contains information about the cell the element is in.
protected abstract  java.lang.String getCellElementTagName()
          Gets the tag name of an element to represent a cell in a row.
 int getDefaultRowHeight()
          Returns the default height of the rows in this RowContainer.
 Element getElement()
          Returns the root element of RowContainer
 EscalatorUpdater getEscalatorUpdater()
          Returns the current EscalatorUpdater used to render cells.
 int getRowCount()
          Gets the number of rows in the current row container.
 TableRowElement getRowElement(int index)
          Gets the row element with given logical index.
protected  int getRowTop(TableRowElement tr)
           
protected  java.lang.String getStylePrimaryName()
          Returns the primary style name of the container.
protected abstract  TableRowElement getTrByVisualIndex(int index)
          Gets the child element that is visually at a certain index
 void insertRows(int index, int numberOfRows)
          Adds rows at a certain index in this row container.
protected  void paintInsertColumns(int offset, int numberOfColumns, boolean frozen)
           
protected  Node paintInsertRow(Node referenceRow, TableRowElement tr, int logicalRowIndex)
          Inserts a single row into the DOM, invoking getEscalatorUpdater() preAttach and postAttach before and after inserting the row, respectively.
protected  java.util.List<TableRowElement> paintInsertRows(int visualIndex, int numberOfRows)
          Actually add rows into the DOM, now that everything can be calculated.
protected  void paintRemoveColumns(int offset, int numberOfColumns)
           
protected  void paintRemoveRow(TableRowElement tr, int logicalRowIndex)
          Removes a row element from the DOM, invoking getEscalatorUpdater() preDetach and postDetach before and after removing the row, respectively.
protected abstract  void paintRemoveRows(int index, int numberOfRows)
          Removes those row elements from the DOM that correspond to the given range of logical indices.
 void reapplyColumnWidths()
          Reapplies all the cells' widths according to the calculated widths in the column configuration.
protected abstract  void reapplyDefaultRowHeights()
          The default height of rows has (most probably) changed.
protected  void reapplyRowHeight(TableRowElement tr, int heightPx)
           
protected  void reapplyRowWidths()
          Applies the total length of the columns to each row element.
protected abstract  void recalculateSectionHeight()
           
abstract  void refreshRows(int index, int numberOfRows)
          Refreshes a range of rows in the current row container.
protected  void removeRowPosition(TableRowElement tr)
           
 void removeRows(int index, int numberOfRows)
          Removes rows at a certain index in the current row container.
 void setColumnFrozen(int column, boolean frozen)
           
 void setDefaultRowHeight(int px)
          The default height of the rows in this RowContainer.
 void setEscalatorUpdater(EscalatorUpdater escalatorUpdater)
          Sets the EscalatorUpdater to use when displaying data in the escalator.
protected  void setRowPosition(TableRowElement tr, int x, int y)
           
protected  void setStylePrimaryName(java.lang.String primaryStyleName)
          The primary style name for the container.
 void updateFreezePosition(int column, double scrollLeft)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected final TableSectionElement root
The table section element (<thead>, <tbody> or <tfoot>) the rows (i.e. <tr> tags) are contained in.


heightOfSection

protected double heightOfSection
The height of the combined rows in the DOM.

Constructor Detail

Escalator.AbstractRowContainer

public Escalator.AbstractRowContainer(TableSectionElement rowContainerElement)
Method Detail

getElement

public Element getElement()
Description copied from interface: RowContainer
Returns the root element of RowContainer

Specified by:
getElement in interface RowContainer
Returns:
RowContainer root element

getCellElementTagName

protected abstract java.lang.String getCellElementTagName()
Gets the tag name of an element to represent a cell in a row.

Usually "th" or "td".

Note: To actually create such an element, use createCellElement(int, int) instead.

Returns:
the tag name for the element to represent cells as
See Also:
createCellElement(int, int)

getEscalatorUpdater

public EscalatorUpdater getEscalatorUpdater()
Description copied from interface: RowContainer
Returns the current EscalatorUpdater used to render cells.

Specified by:
getEscalatorUpdater in interface RowContainer
Returns:
the current escalator updater

setEscalatorUpdater

public void setEscalatorUpdater(EscalatorUpdater escalatorUpdater)
Sets the EscalatorUpdater to use when displaying data in the escalator.

Implementation detail: This method does no DOM modifications (i.e. is very cheap to call) if there is no data for rows or columns when this method is called.

Specified by:
setEscalatorUpdater in interface RowContainer
Parameters:
escalatorUpdater - the escalator updater to use to render cells. May not be null
See Also:
Escalator.hasColumnAndRowData()

removeRows

public void removeRows(int index,
                       int numberOfRows)
Removes rows at a certain index in the current row container.

Implementation detail: This method does no DOM modifications (i.e. is very cheap to call) if there are no rows in the DOM when this method is called.

Specified by:
removeRows in interface RowContainer
Parameters:
index - the index of the first row to be removed
numberOfRows - the number of rows to remove, starting from the index
See Also:
Escalator.hasSomethingInDom()

paintRemoveRows

protected abstract void paintRemoveRows(int index,
                                        int numberOfRows)
Removes those row elements from the DOM that correspond to the given range of logical indices. This may be fewer than numberOfRows , even zero, if not all the removed rows are actually visible.

The implementation must call #paintRemoveRow(Element, int) for each row that is removed from the DOM.

Parameters:
index - the logical index of the first removed row
numberOfRows - number of logical rows to remove

paintRemoveRow

protected void paintRemoveRow(TableRowElement tr,
                              int logicalRowIndex)
Removes a row element from the DOM, invoking getEscalatorUpdater() preDetach and postDetach before and after removing the row, respectively.

This method must be called for each removed DOM row by any paintRemoveRows(int, int) implementation.

Parameters:
tr - the row element to remove.

assertArgumentsAreValidAndWithinRange

protected void assertArgumentsAreValidAndWithinRange(int index,
                                                     int numberOfRows)
                                              throws java.lang.IllegalArgumentException,
                                                     java.lang.IndexOutOfBoundsException
Throws:
java.lang.IllegalArgumentException
java.lang.IndexOutOfBoundsException

getRowCount

public int getRowCount()
Description copied from interface: RowContainer
Gets the number of rows in the current row container.

Specified by:
getRowCount in interface RowContainer
Returns:
the number of rows in the current row container

insertRows

public void insertRows(int index,
                       int numberOfRows)
Adds rows at a certain index in this row container.

The new rows will be inserted between the row at the index, and the row before (an index of 0 means that the rows are inserted at the beginning). Therefore, the rows currently at the index and afterwards will be moved downwards.

The contents of the inserted rows will subsequently be queried from the escalator updater.

Note: Only the contents of the inserted rows will be rendered. If inserting new rows affects the contents of existing rows, RowContainer.refreshRows(int, int) needs to be called for those rows separately.

Implementation detail: This method does no DOM modifications (i.e. is very cheap to call) if there is no data for columns when this method is called.

Specified by:
insertRows in interface RowContainer
Parameters:
index - the index of the row before which new rows are inserted, or RowContainer.getRowCount() to add rows at the end
numberOfRows - the number of rows to insert after the index
See Also:
Escalator.hasColumnAndRowData()

paintInsertRows

protected java.util.List<TableRowElement> paintInsertRows(int visualIndex,
                                                          int numberOfRows)
Actually add rows into the DOM, now that everything can be calculated.

Parameters:
visualIndex - the DOM index to add rows into
numberOfRows - the number of rows to insert
Returns:
a list of the added row elements

paintInsertRow

protected Node paintInsertRow(Node referenceRow,
                              TableRowElement tr,
                              int logicalRowIndex)
Inserts a single row into the DOM, invoking getEscalatorUpdater() preAttach and postAttach before and after inserting the row, respectively. The row should have its cells already inserted.

Parameters:
referenceRow - the row after which to insert or null if insert as first
tr - the row to be inserted
logicalRowIndex - the logical index of the inserted row
Returns:
the inserted row to be used as the new reference

recalculateSectionHeight

protected abstract void recalculateSectionHeight()

calculateEstimatedTotalRowHeight

protected int calculateEstimatedTotalRowHeight()
Returns the estimated height of all rows in the row container.

The estimate is promised to be correct as long as there are no rows with calculated heights.


refreshRows

public abstract void refreshRows(int index,
                                 int numberOfRows)
Refreshes a range of rows in the current row container.

The data for the refreshed rows are queried from the current cell renderer.

Implementation detail: This method does no DOM modifications (i.e. is very cheap to call) if there is no data for columns when this method is called.

Specified by:
refreshRows in interface RowContainer
Parameters:
index - the index of the first row that will be updated
numberOfRows - the number of rows to update, starting from the index
See Also:
Escalator.hasColumnAndRowData()

createCellElement

public TableCellElement createCellElement(int height,
                                          int width)
Create and setup an empty cell element.

Parameters:
width - the width of the cell, in pixels
height - the height of the cell, in pixels
Returns:
a set-up empty cell element

getRowElement

public TableRowElement getRowElement(int index)
Description copied from interface: RowContainer
Gets the row element with given logical index. For lazy loaded containers such as Escalators BodyRowContainer visibility should be checked before calling this function. See Escalator.getVisibleRowRange().

Specified by:
getRowElement in interface RowContainer
Parameters:
index - the logical index of the element to retrieve
Returns:
the element at position index

getTrByVisualIndex

protected abstract TableRowElement getTrByVisualIndex(int index)
                                               throws java.lang.IndexOutOfBoundsException
Gets the child element that is visually at a certain index

Parameters:
index - the index of the element to retrieve
Returns:
the element at position index
Throws:
java.lang.IndexOutOfBoundsException - if index is not valid within root

paintRemoveColumns

protected void paintRemoveColumns(int offset,
                                  int numberOfColumns)

paintInsertColumns

protected void paintInsertColumns(int offset,
                                  int numberOfColumns,
                                  boolean frozen)

setColumnFrozen

public void setColumnFrozen(int column,
                            boolean frozen)

updateFreezePosition

public void updateFreezePosition(int column,
                                 double scrollLeft)

calculateMaxColWidth

public int calculateMaxColWidth(int index)
Iterates through all the cells in a column and returns the width of the widest element in this RowContainer.

Parameters:
index - the index of the column to inspect
Returns:
the pixel width of the widest element in the indicated column

reapplyColumnWidths

public void reapplyColumnWidths()
Reapplies all the cells' widths according to the calculated widths in the column configuration.


reapplyRowWidths

protected void reapplyRowWidths()
Applies the total length of the columns to each row element.

Note: In contrast to reapplyColumnWidths(), this method only modifies the width of the <tr> element, not the cells within.


setStylePrimaryName

protected void setStylePrimaryName(java.lang.String primaryStyleName)
The primary style name for the container.

Parameters:
primaryStyleName - the style name to use as prefix for all row and cell style names.

getStylePrimaryName

protected java.lang.String getStylePrimaryName()
Returns the primary style name of the container.

Returns:
The primary style name or null if not set.

setDefaultRowHeight

public void setDefaultRowHeight(int px)
                         throws java.lang.IllegalArgumentException
Description copied from interface: RowContainer
The default height of the rows in this RowContainer.

Specified by:
setDefaultRowHeight in interface RowContainer
Parameters:
px - the default height in pixels of the rows in this RowContainer
Throws:
java.lang.IllegalArgumentException - if px < 1
See Also:
RowContainer.getDefaultRowHeight()

getDefaultRowHeight

public int getDefaultRowHeight()
Description copied from interface: RowContainer
Returns the default height of the rows in this RowContainer.

This value will be equal to RowContainer.INITIAL_DEFAULT_ROW_HEIGHT if the Escalator has not yet had a chance to autodetect the row height, or no explicit value has yet given via RowContainer.setDefaultRowHeight(int)

Specified by:
getDefaultRowHeight in interface RowContainer
Returns:
the default height of the rows in this RowContainer, in pixels
See Also:
RowContainer.setDefaultRowHeight(int)

reapplyDefaultRowHeights

protected abstract void reapplyDefaultRowHeights()
The default height of rows has (most probably) changed.

Make sure that the displayed rows with a default height are updated in height and top position.

Note:This implementation should not call Escalator.recalculateElementSizes() - it is done by the discretion of the caller of this method.


reapplyRowHeight

protected void reapplyRowHeight(TableRowElement tr,
                                int heightPx)

setRowPosition

protected void setRowPosition(TableRowElement tr,
                              int x,
                              int y)

getRowTop

protected int getRowTop(TableRowElement tr)

removeRowPosition

protected void removeRowPosition(TableRowElement tr)

autodetectRowHeight

public void autodetectRowHeight()

getCell

public Cell getCell(Element element)
Description copied from interface: RowContainer
Returns the cell object which contains information about the cell the element is in.

Specified by:
getCell in interface RowContainer
Parameters:
element - The element to get the cell for. If element is not present in row container then null is returned.
Returns:
the cell of the element, or null if element is not present in the RowContainer.


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.