Class AbstractCellTable<T>

    • Constructor Detail

      • AbstractCellTable

        public AbstractCellTable​(Element elem,
                                 int pageSize,
                                 AbstractCellTable.Resources resources,
                                 ProvidesKey<T> keyProvider)
        Constructs a table with the given page size, the specified AbstractCellTable.Style, and the given key provider.
        Parameters:
        elem - the parent Element
        pageSize - the page size
        resources - the resources to apply to the widget
        keyProvider - an instance of ProvidesKey, or null if the record object should act as its own key
      • AbstractCellTable

        public AbstractCellTable​(Widget widget,
                                 int pageSize,
                                 AbstractCellTable.Resources resources,
                                 ProvidesKey<T> keyProvider)
        Constructs a table with the given page size, the specified AbstractCellTable.Style, and the given key provider.
        Parameters:
        widget - the parent widget
        pageSize - the page size
        resources - the resources to apply to the widget
        keyProvider - an instance of ProvidesKey, or null if the record object should act as its own key
    • Method Detail

      • addColumn

        public void addColumn​(Column<T,​?> col)
        Adds a column to the end of the table.
        Parameters:
        col - the column to be added
      • addColumn

        public void addColumn​(Column<T,​?> col,
                              Header<?> header)
        Adds a column to the end of the table with an associated header.
        Parameters:
        col - the column to be added
        header - the associated Header
      • addColumn

        public void addColumn​(Column<T,​?> col,
                              Header<?> header,
                              Header<?> footer)
        Adds a column to the end of the table with an associated header and footer.
        Parameters:
        col - the column to be added
        header - the associated Header
        footer - the associated footer (as a Header object)
      • addColumn

        public void addColumn​(Column<T,​?> col,
                              java.lang.String headerString)
        Adds a column to the end of the table with an associated String header.
        Parameters:
        col - the column to be added
        headerString - the associated header text, as a String
      • addColumn

        public void addColumn​(Column<T,​?> col,
                              SafeHtml headerHtml)
        Adds a column to the end of the table with an associated SafeHtml header.
        Parameters:
        col - the column to be added
        headerHtml - the associated header text, as safe HTML
      • addColumn

        public void addColumn​(Column<T,​?> col,
                              java.lang.String headerString,
                              java.lang.String footerString)
        Adds a column to the end of the table with an associated String header and footer.
        Parameters:
        col - the column to be added
        headerString - the associated header text, as a String
        footerString - the associated footer text, as a String
      • addColumn

        public void addColumn​(Column<T,​?> col,
                              SafeHtml headerHtml,
                              SafeHtml footerHtml)
        Adds a column to the end of the table with an associated SafeHtml header and footer.
        Parameters:
        col - the column to be added
        headerHtml - the associated header text, as safe HTML
        footerHtml - the associated footer text, as safe HTML
      • addColumnStyleName

        public abstract void addColumnStyleName​(int index,
                                                java.lang.String styleName)
        Add a style name to the col element at the specified index, creating it if necessary.
        Parameters:
        index - the column index
        styleName - the style name to add
      • clearColumnWidth

        public void clearColumnWidth​(Column<T,​?> column)
        Clear the width of the specified Column.
        Parameters:
        column - the column
      • clearColumnWidth

        public void clearColumnWidth​(java.lang.Integer column)
        Clear the width of the specified Column.
        Parameters:
        column - the column index
      • flush

        public void flush()
        Flush all pending changes to the table and render immediately.

        Modifications to the table, such as adding columns or setting data, are not rendered immediately. Instead, changes are coalesced at the end of the current event loop to avoid rendering the table multiple times. Use this method to force the table to render all pending modifications immediately.

      • getColumn

        public Column<T,​?> getColumn​(int col)
        Get the column at the specified index.
        Parameters:
        col - the index of the column to retrieve
        Returns:
        the Column at the index
      • getColumnCount

        public int getColumnCount()
        Get the number of columns in the table.
        Returns:
        the column count
      • getColumnIndex

        public int getColumnIndex​(Column<T,​?> column)
        Get the index of the specified column.
        Parameters:
        column - the column to search for
        Returns:
        the index of the column, or -1 if not found
      • getEmptyTableWidget

        public Widget getEmptyTableWidget()
        Get the widget displayed when the table has no rows.
        Returns:
        the empty table widget
      • getFooter

        public Header<?> getFooter​(int index)
        Get the Header from the footer section that was added with a Column.
      • getHeader

        public Header<?> getHeader​(int index)
        Get the Header from the header section that was added with a Column.
      • getKeyboardSelectedColumn

        public int getKeyboardSelectedColumn()
        Get the index of the column that is currently selected via the keyboard.
        Returns:
        the currently selected column, or -1 if none selected
      • getKeyboardSelectedSubRow

        public int getKeyboardSelectedSubRow()
        Get the index of the sub row that is currently selected via the keyboard. If the row value maps to one rendered row element, the subrow is 0.
        Returns:
        the currently selected subrow, or -1 if none selected
      • getLoadingIndicator

        public Widget getLoadingIndicator()
        Get the widget displayed when the data is loading.
        Returns:
        the loading indicator
      • getRowElement

        public TableRowElement getRowElement​(int row)
        Get the TableRowElement for the specified row. If the row element has not been created, null is returned.
        Parameters:
        row - the row index
        Returns:
        the row element, or null if it doesn't exists
        Throws:
        java.lang.IndexOutOfBoundsException - if the row index is outside of the current page
      • getRowStyles

        public RowStyles<T> getRowStyles()
        Gets the object used to determine how a row is styled.
        Returns:
        the RowStyles object if set, null if not
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col)
        Inserts a column into the table at the specified index.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col,
                                 Header<?> header)
        Inserts a column into the table at the specified index with an associated header.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
        header - the associated Header
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col,
                                 Header<?> header,
                                 Header<?> footer)
        Inserts a column into the table at the specified index with an associated header and footer.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
        header - the associated Header
        footer - the associated footer (as a Header object)
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is out of range
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col,
                                 java.lang.String headerString)
        Inserts a column into the table at the specified index with an associated String header.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
        headerString - the associated header text, as a String
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col,
                                 SafeHtml headerHtml)
        Inserts a column into the table at the specified index with an associated SafeHtml header.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
        headerHtml - the associated header text, as safe HTML
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col,
                                 java.lang.String headerString,
                                 java.lang.String footerString)
        Inserts a column into the table at the specified index with an associated String header and footer.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
        headerString - the associated header text, as a String
        footerString - the associated footer text, as a String
      • insertColumn

        public void insertColumn​(int beforeIndex,
                                 Column<T,​?> col,
                                 SafeHtml headerHtml,
                                 SafeHtml footerHtml)
        Inserts a column into the table at the specified index with an associated SafeHtml header and footer.
        Parameters:
        beforeIndex - the index to insert the column
        col - the column to be added
        headerHtml - the associated header text, as safe HTML
        footerHtml - the associated footer text, as safe HTML
      • isAutoFooterRefreshDisabled

        public boolean isAutoFooterRefreshDisabled()
        Check if auto footer refresh is enabled or disabled.
        Returns:
        true if disabled, false if enabled
        See Also:
        setAutoFooterRefreshDisabled(boolean)
      • isAutoHeaderRefreshDisabled

        public boolean isAutoHeaderRefreshDisabled()
        Check if auto header refresh is enabled or disabled.
        Returns:
        true if disabled, false if enabled
        See Also:
        setAutoHeaderRefreshDisabled(boolean)
      • isSkipRowHoverCheck

        public boolean isSkipRowHoverCheck()
        Gets the skipRowHoverCheck flag. If true, the CellTable will not check for row-level hover events (MOUSEOVER and MOUSEOUT).
        Returns:
        the flag value
      • isSkipRowHoverFloatElementCheck

        public boolean isSkipRowHoverFloatElementCheck()
        Gets the skipRowHoverFloatElementCheck flag. If true, the CellTable will not check for floating (fixed position) elements over the hovered row.
        Returns:
        the flag value
      • isSkipRowHoverStyleUpdate

        public boolean isSkipRowHoverStyleUpdate()
        Gets the skipRowHoverStyleUpdate flag. If true, the CellTable will not update the row's style on row-level hover events (MOUSEOVER and MOUSEOUT).
        Returns:
        the flag value
      • redrawFooters

        public void redrawFooters()
        Redraw the table's footers. The footers will be re-rendered synchronously.
      • redrawHeaders

        public void redrawHeaders()
        Redraw the table's headers. The headers will be re-rendered synchronously.
      • removeColumn

        public void removeColumn​(Column<T,​?> col)
        Remove a column.
        Parameters:
        col - the column to remove
      • removeColumn

        public void removeColumn​(int index)
        Remove a column.
        Parameters:
        index - the column index
      • removeColumnStyleName

        public abstract void removeColumnStyleName​(int index,
                                                   java.lang.String styleName)
        Remove a style from the col element at the specified index.
        Parameters:
        index - the column index
        styleName - the style name to remove
      • setAutoFooterRefreshDisabled

        public void setAutoFooterRefreshDisabled​(boolean disabled)
        Enable or disable auto footer refresh when row data is changed. By default, footers are refreshed every time the row data changes in case the headers depend on the current row data. If the headers do not depend on the current row data, you can disable this feature to improve performance.

        Note that headers will still refresh when columns are added or removed, regardless of whether or not this feature is enabled.

      • setAutoHeaderRefreshDisabled

        public void setAutoHeaderRefreshDisabled​(boolean disabled)
        Enable or disable auto header refresh when row data is changed. By default, headers are refreshed every time the row data changes in case the footers depend on the current row data. If the footers do not depend on the current row data, you can disable this feature to improve performance.

        Note that footers will still refresh when columns are added or removed, regardless of whether or not this feature is enabled.

      • setColumnWidth

        public void setColumnWidth​(Column<T,​?> column,
                                   java.lang.String width)
        Set the width of a Column. The width will persist with the column and takes precedence of any width set via setColumnWidth(int, String).
        Parameters:
        column - the column
        width - the width of the column
      • setColumnWidth

        public void setColumnWidth​(Column<T,​?> column,
                                   double width,
                                   Style.Unit unit)
        Set the width of a Column. The width will persist with the column and takes precedence of any width set via setColumnWidth(int, double, Unit).
        Parameters:
        column - the column
        width - the width of the column
        unit - the Style.Unit of measurement
      • setColumnWidth

        public void setColumnWidth​(int column,
                                   double width,
                                   Style.Unit unit)
        Set the width of a Column.
        Parameters:
        column - the column
        width - the width of the column
        unit - the Style.Unit of measurement
      • setColumnWidth

        public void setColumnWidth​(int column,
                                   java.lang.String width)
        Set the width of a Column.
        Parameters:
        column - the column
        width - the width of the column
      • setEmptyTableWidget

        @UiChild(tagname="emptyTableWidget",
                 limit=1)
        public void setEmptyTableWidget​(Widget widget)
        Set the widget to display when the table has no rows.
        Parameters:
        widget - the empty table widget, or null to disable
      • setFooterBuilder

        public void setFooterBuilder​(FooterBuilder<T> builder)
        Set the HeaderBuilder used to build the footer section of the table.
      • setHeaderBuilder

        public void setHeaderBuilder​(HeaderBuilder<T> builder)
        Set the HeaderBuilder used to build the header section of the table.
      • setKeyboardSelectedColumn

        public final void setKeyboardSelectedColumn​(int column)
        Set the keyboard selected column index.

        If keyboard selection is disabled, this method does nothing.

        If the keyboard selected column is greater than the number of columns in the keyboard selected row, the last column in the row is selected, but the column index is remembered.

        Parameters:
        column - the column index, greater than or equal to zero
      • setKeyboardSelectedColumn

        public void setKeyboardSelectedColumn​(int column,
                                              boolean stealFocus)
        Set the keyboard selected column index and optionally focus on the new cell.
        Parameters:
        column - the column index, greater than or equal to zero
        stealFocus - true to focus on the new column
        See Also:
        setKeyboardSelectedColumn(int)
      • setKeyboardSelectedRow

        public void setKeyboardSelectedRow​(int row,
                                           int subrow,
                                           boolean stealFocus)
        Set the keyboard selected row and subrow, optionally focus on the new row.
        Parameters:
        row - the row index relative to the page start
        subrow - the row index of the child row
        stealFocus - true to focus on the new row
        See Also:
        AbstractHasData.setKeyboardSelectedRow(int)
      • setLoadingIndicator

        @UiChild(tagname="loadingIndicator",
                 limit=1)
        public void setLoadingIndicator​(Widget widget)
        Set the widget to display when the data is loading.
        Parameters:
        widget - the loading indicator, or null to disable
      • setRowStyles

        public void setRowStyles​(RowStyles<T> rowStyles)
        Sets the object used to determine how a row is styled; the change will take effect the next time that the table is rendered.
        Parameters:
        rowStyles - a RowStyles object
      • setSkipRowHoverCheck

        public void setSkipRowHoverCheck​(boolean skipRowHoverCheck)
        Sets the skipRowHoverCheck flag. If set, the CellTable will not check for row-level hover events (MOUSEOVER and MOUSEOUT).
        Parameters:
        skipRowHoverCheck - the new flag value
      • setSkipRowHoverFloatElementCheck

        public void setSkipRowHoverFloatElementCheck​(boolean skipRowHoverFloatElementCheck)
        Sets the skipRowHoverFloatElementCheck flag. If set, the CellTable will not not check for floating (fixed position) elements over the hovered row.
        Parameters:
        skipRowHoverFloatElementCheck - the new flag value
      • setSkipRowHoverStyleUpdate

        public void setSkipRowHoverStyleUpdate​(boolean skipRowHoverStyleUpdate)
        Sets the skipRowHoverStyleUpdate flag. If set, the CellTable will not update the row's style on row-level hover events (MOUSEOVER and MOUSEOUT).
        Parameters:
        skipRowHoverCheck - the new flag value
      • setTableBuilder

        public void setTableBuilder​(CellTableBuilder<T> tableBuilder)
        Specify the CellTableBuilder that will be used to render the row values into the table.
      • convertToElements

        protected Element convertToElements​(SafeHtml html)
        Description copied from class: AbstractHasData
        Convert the specified HTML into DOM elements and return the parent of the DOM elements.
        Overrides:
        convertToElements in class AbstractHasData<T>
        Parameters:
        html - the HTML to convert
        Returns:
        the parent element
      • dependsOnSelection

        protected boolean dependsOnSelection()
        Description copied from class: AbstractHasData
        Check whether or not the cells in the view depend on the selection state.
        Specified by:
        dependsOnSelection in class AbstractHasData<T>
        Returns:
        true if cells depend on selection, false if not
      • doSetColumnWidth

        protected abstract void doSetColumnWidth​(int column,
                                                 java.lang.String width)
        Set the width of a column.
        Parameters:
        column - the column index
        width - the width, or null to clear the width
      • doSetHeaderVisible

        protected abstract void doSetHeaderVisible​(boolean isFooter,
                                                   boolean isVisible)
        Show or hide a header section.
        Parameters:
        isFooter - true for the footer, false for the header
        isVisible - true to show, false to hide
      • getChildElement

        protected TableRowElement getChildElement​(int row)
        Get the element that represents the specified index.

        The row element may not be the same as the TR element at the specified index if some row values are rendered with additional rows.

        Overrides:
        getChildElement in class AbstractHasData<T>
        Parameters:
        row - the row index, relative to the page start
        Returns:
        the row element, or null if it doesn't exists
        Throws:
        java.lang.IndexOutOfBoundsException - if the row index is outside of the current page
      • getRealColumnCount

        protected int getRealColumnCount()
        Get the real column count, which is the greater of the number of Columns or the maximum index of a column with a defined column width.
      • getTableBodyElement

        protected abstract TableSectionElement getTableBodyElement()
        Get the tbody element that contains the render row values.
      • getTableFootElement

        protected abstract TableSectionElement getTableFootElement()
        Get the tfoot element that contains the footers.
      • getTableHeadElement

        protected abstract TableSectionElement getTableHeadElement()
        Get the thead element that contains the headers.
      • isKeyboardNavigationSuppressed

        protected boolean isKeyboardNavigationSuppressed()
        Description copied from class: AbstractHasData
        Check if keyboard navigation is being suppressed, such as when the user is editing a cell.
        Specified by:
        isKeyboardNavigationSuppressed in class AbstractHasData<T>
        Returns:
        true if suppressed, false if not
      • refreshColumnWidths

        protected void refreshColumnWidths()
      • replaceChildren

        protected void replaceChildren​(java.util.List<T> values,
                                       int start,
                                       SafeHtml html)
        Description copied from class: AbstractHasData
        Convert the specified HTML into DOM elements and replace the existing elements starting at the specified index. If the number of children specified exceeds the existing number of children, the remaining children should be appended.
        Overrides:
        replaceChildren in class AbstractHasData<T>
        Parameters:
        values - the values of the new children
        start - the start index to be replaced, relative to the page start
        html - the html to render, or null if AbstractHasData.renderRowValues(SafeHtmlBuilder, List, int, SelectionModel) throws an UnsupportedOperationException
      • resetFocusOnCell

        protected boolean resetFocusOnCell()
        Description copied from class: AbstractHasData
        Reset focus on the currently focused cell.
        Specified by:
        resetFocusOnCell in class AbstractHasData<T>
        Returns:
        true if focus is taken, false if not
      • setKeyboardSelected

        protected void setKeyboardSelected​(int index,
                                           boolean selected,
                                           boolean stealFocus)
        Description copied from class: AbstractHasData
        Update an element to reflect its keyboard selected state.
        Specified by:
        setKeyboardSelected in class AbstractHasData<T>
        Parameters:
        index - the index of the element
        selected - true if selected, false if not
        stealFocus - true if the row should steal focus, false if not
      • getColumnWidth

        java.lang.String getColumnWidth​(int columnIndex)
        Get the column width. Associating a width with a Column takes precedence over setting the width of a column index.
        Parameters:
        columnIndex - the column index
        Returns:
        the column width, or null if none specified
      • getSubRowElement

        protected TableRowElement getSubRowElement​(int absRow,
                                                   int subrow)
        Get a subrow element given the index of the row value and the sub row index.
        Parameters:
        absRow - the absolute row value index
        subrow - the index of the subrow beneath the row.
        Returns:
        the row element, or null if not found