Class AbstractHeaderOrFooterBuilder<T>
- java.lang.Object
-
- com.google.gwt.user.cellview.client.AbstractHeaderOrFooterBuilder<T>
-
- Type Parameters:
T
- the data type of the table
- All Implemented Interfaces:
FooterBuilder<T>
,HeaderBuilder<T>
- Direct Known Subclasses:
DefaultHeaderOrFooterBuilder
public abstract class AbstractHeaderOrFooterBuilder<T> extends java.lang.Object implements HeaderBuilder<T>, FooterBuilder<T>
Default implementation ofHeaderBuilder
that renders columns.
-
-
Constructor Summary
Constructors Constructor Description AbstractHeaderOrFooterBuilder(AbstractCellTable<T> table, boolean isFooter)
Create a new DefaultHeaderBuilder for the header of footer section.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TableSectionBuilder
buildFooter()
Builds the DOM subtree for this footer.TableSectionBuilder
buildHeader()
Builds the DOM subtree for this header.protected abstract boolean
buildHeaderOrFooterImpl()
Implementation that builds the header or footer using the convenience methods in this class.protected void
enableColumnHandlers(ElementBuilderBase<?> builder, Column<T,?> column)
Enables column-specific event handling for the specified element.Column<T,?>
getColumn(Element elem)
Given an element in the DOM subtree returned by the most recent call toHeaderBuilder.buildHeader()
, returns the Column that should be the target of any button clicks or other events on that element, or null if the events should be discarded.protected Header<?>
getHeader(int index)
Get the header or footer at the specified index.Header<?>
getHeader(Element elem)
int
getRowIndex(TableRowElement row)
Get the row index from the associatedTableRowElement
(an TR element).protected AbstractCellTable<T>
getTable()
boolean
isBuildingFooter()
Check if this builder is building a header or footer table.boolean
isColumn(Element elem)
Check if an element contains aColumn
.boolean
isHeader(Element elem)
Check if an element contains aHeader
.boolean
isSortIconStartOfLine()
Check if the icon is located at the start or end of the line.protected <H> void
renderHeader(ElementBuilderBase<?> out, Cell.Context context, Header<H> header)
Renders a given Header into a given ElementBuilderBase.protected void
renderSortableHeader(ElementBuilderBase<?> out, Cell.Context context, Header<?> header, boolean isSorted, boolean isSortAscending)
Render a header, including a sort icon if the column is sortable and sorted.void
setSortIconStartOfLine(boolean isStartOfLine)
Set the position of the sort icon to the start or end of the line.protected TableRowBuilder
startRow()
Add a header (or footer) row to the table, below any rows previously added.
-
-
-
Constructor Detail
-
AbstractHeaderOrFooterBuilder
public AbstractHeaderOrFooterBuilder(AbstractCellTable<T> table, boolean isFooter)
Create a new DefaultHeaderBuilder for the header of footer section.- Parameters:
table
- the table being builtisFooter
- true if building the footer, false if the header
-
-
Method Detail
-
buildFooter
public final TableSectionBuilder buildFooter()
Description copied from interface:FooterBuilder
Builds the DOM subtree for this footer. The root of the subtree must be a TFOOT element, as appropriate. This method may be called multiple times and should return a new DOM subtree each time.If the footer is empty, return null.
- Specified by:
buildFooter
in interfaceFooterBuilder<T>
- Returns:
- a
TableSectionBuilder
representing the new footer, or null if the footer is empty
-
buildHeader
public final TableSectionBuilder buildHeader()
Description copied from interface:HeaderBuilder
Builds the DOM subtree for this header. The root of the subtree must be a THEAD element, as appropriate. This method may be called multiple times and should return a new DOM subtree each time.If the header is empty, return null.
- Specified by:
buildHeader
in interfaceHeaderBuilder<T>
- Returns:
- a
TableSectionBuilder
representing the new header, or null if the header is empty
-
getColumn
public Column<T,?> getColumn(Element elem)
Description copied from interface:HeaderBuilder
Given an element in the DOM subtree returned by the most recent call toHeaderBuilder.buildHeader()
, returns the Column that should be the target of any button clicks or other events on that element, or null if the events should be discarded. The column is used to support features such as column sorting.- Specified by:
getColumn
in interfaceFooterBuilder<T>
- Specified by:
getColumn
in interfaceHeaderBuilder<T>
- Parameters:
elem
- the element that the contains column- Returns:
- the immediate column contained by the element
-
getHeader
public Header<?> getHeader(Element elem)
Description copied from interface:HeaderBuilder
If you want to handle browser events using a subclass ofHeader
, implement this method to return the appropriate instance and cell table will forward events originating in the element to theHeader
. Return null if events from the element should be discarded.- Specified by:
getHeader
in interfaceFooterBuilder<T>
- Specified by:
getHeader
in interfaceHeaderBuilder<T>
- Parameters:
elem
- the element that the contains header- Returns:
- the immediate
Header
contained by the element
-
getRowIndex
public int getRowIndex(TableRowElement row)
Description copied from interface:HeaderBuilder
Get the row index from the associatedTableRowElement
(an TR element).- Specified by:
getRowIndex
in interfaceFooterBuilder<T>
- Specified by:
getRowIndex
in interfaceHeaderBuilder<T>
- Parameters:
row
- the row element- Returns:
- the row value index
-
isBuildingFooter
public boolean isBuildingFooter()
Check if this builder is building a header or footer table.- Returns:
- true if a footer, false if a header
-
isColumn
public boolean isColumn(Element elem)
Description copied from interface:HeaderBuilder
Check if an element contains aColumn
. This method should return false if and only ifHeaderBuilder.getColumn(Element)
would return null.- Specified by:
isColumn
in interfaceFooterBuilder<T>
- Specified by:
isColumn
in interfaceHeaderBuilder<T>
- Parameters:
elem
- the element of interest
-
isHeader
public boolean isHeader(Element elem)
Description copied from interface:HeaderBuilder
Check if an element contains aHeader
. This method should return false if and only ifHeaderBuilder.getHeader(Element)
would return null.- Specified by:
isHeader
in interfaceFooterBuilder<T>
- Specified by:
isHeader
in interfaceHeaderBuilder<T>
- Parameters:
elem
- the element of interest
-
isSortIconStartOfLine
public boolean isSortIconStartOfLine()
Check if the icon is located at the start or end of the line. The start of the line refers to the left side in LTR mode and the right side in RTL mode. The default location is the start of the line.
-
setSortIconStartOfLine
public void setSortIconStartOfLine(boolean isStartOfLine)
Set the position of the sort icon to the start or end of the line. The start of the line refers to the left side in LTR mode and the right side in RTL mode. The default location is the start of the line.
-
buildHeaderOrFooterImpl
protected abstract boolean buildHeaderOrFooterImpl()
Implementation that builds the header or footer using the convenience methods in this class.- Returns:
- true if the header contains content, false if empty
-
enableColumnHandlers
protected final void enableColumnHandlers(ElementBuilderBase<?> builder, Column<T,?> column)
Enables column-specific event handling for the specified element. If a column is sortable, then clicking on the element or a child of the element will trigger a sort event.- Parameters:
builder
- the builder to associate with the column. The builder should be a child element of a row returned bystartRow()
and must be in a state where an attribute can be added.column
- the column to associate
-
getHeader
protected final Header<?> getHeader(int index)
Get the header or footer at the specified index.- Parameters:
index
- the column index of the header- Returns:
- the header or footer, depending on the value of isFooter
-
getTable
protected AbstractCellTable<T> getTable()
-
renderHeader
protected final <H> void renderHeader(ElementBuilderBase<?> out, Cell.Context context, Header<H> header)
Renders a given Header into a given ElementBuilderBase. This method ensures that the CellTable widget will handle events events originating in the Header.- Type Parameters:
H
- the data type of the header- Parameters:
out
- theElementBuilderBase
to render into. The builder should be a child element of a row returned bystartRow()
and must be in a state that allows both attributes and elements to be addedcontext
- theCell.Context
of the header being renderedheader
- theHeader
to render
-
renderSortableHeader
protected final void renderSortableHeader(ElementBuilderBase<?> out, Cell.Context context, Header<?> header, boolean isSorted, boolean isSortAscending)
Render a header, including a sort icon if the column is sortable and sorted.- Parameters:
out
- the builder to render intoheader
- the header to rendercontext
- the context of the headerisSorted
- true if the column is sortedisSortAscending
- indicated the sort order, if sorted
-
startRow
protected final TableRowBuilder startRow()
Add a header (or footer) row to the table, below any rows previously added.- Returns:
- the row to add
-
-