Class TableRow

  • All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable

    @Tag("tr")
    public class TableRow
    extends com.vaadin.flow.component.HtmlComponent
    Represents the table row element (<trow>). Can contain a list of table cells.
    Author:
    Stefan Uebe
    See Also:
    TableCell, TableDataCell, TableHeaderCell, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      TableRow()  
      TableRow​(com.vaadin.flow.component.Component... cells)
      Creates new Table row with given components wrapped as cells.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCells​(com.vaadin.flow.component.Component... components)
      Wrapps given components into table cells and adds them to this instance.
      void addCells​(String... contents)
      Adds data cells with given string content
      void addCells​(TableCell... cells)
      Adds the given cells to this instance.
      TableDataCell addDataCell()
      Adds a data cell instance to this row.
      TableDataCell[] addDataCells​(int cells)
      Adds multiple data cells to this instance based on the given integer (must be greater than 0).
      TableHeaderCell addHeaderCell()
      Adds a header cell instance to this row.
      TableHeaderCell[] addHeaderCells​(int cells)
      Adds multiple header cells to this instance based on the given integer (must be greater than 0).
      void addHeaderCells​(com.vaadin.flow.component.Component... components)
      Wrapps given components into header cells and adds them to this instance.
      void addHeaderCells​(String... contents)
      Adds header cells with given string content
      Optional<TableCell> getCell​(int index)
      Returns the cell with the given index or an empty optional, if the index is out of bounds.
      List<TableCell> getCells()
      Returns all cells of this row as a list.
      Optional<TableDataCell> getDataCell​(int dataCellIndex)
      Returns the data cell with the given index or an empty optional, if the index is out of bounds or if no data cell has been found for that index.
      List<TableDataCell> getDataCells()
      Returns all data cells of this row as a list.
      Optional<TableHeaderCell> getHeaderCell​(int headerCellIndex)
      Returns the header cell with the given index or an empty optional, if the index is out of bounds or if no header cell has been found for that index.
      List<TableHeaderCell> getHeaderCells()
      Returns all header cells of this row as a list.
      void removeAllCells()
      Removes all cells from this instance.
      void removeAllDataCells()
      Removes all data cells from this instance.
      void removeAllHeaderCells()
      Removes all header cells from this instance.
      void removeCell​(int index)
      Removes the cell with the given index.
      void removeCells​(TableCell... cells)
      Removes the given cells from this instance.
      void removeDataCell​(int dataCellIndex)
      Removes the data cell with the given index.
      void removeHeaderCell​(int headerCellIndex)
      Removes the header cell with the given index.
      Stream<TableCell> streamCells()
      Returns all cells of this row as a stream.
      Stream<TableDataCell> streamDataCells()
      Returns all data cells of this row as a stream.
      Stream<TableHeaderCell> streamHeaderCells()
      Returns all header cells of this row as a stream.
      • Methods inherited from class com.vaadin.flow.component.HtmlComponent

        getTitle, setTitle
      • Methods inherited from class com.vaadin.flow.component.Component

        addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

        addDetachListener
      • Methods inherited from interface com.vaadin.flow.component.HasElement

        getElement
      • Methods inherited from interface com.vaadin.flow.component.HasSize

        getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
      • Methods inherited from interface com.vaadin.flow.component.HasStyle

        addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
    • Constructor Detail

      • TableRow

        public TableRow()
      • TableRow

        public TableRow​(com.vaadin.flow.component.Component... cells)
        Creates new Table row with given components wrapped as cells.
        Parameters:
        cells - the components to be placed in cells of the row
    • Method Detail

      • addDataCell

        public TableDataCell addDataCell()
        Adds a data cell instance to this row. The created cell is returned for further configuration.
        Returns:
        the created cell
      • addHeaderCell

        public TableHeaderCell addHeaderCell()
        Adds a header cell instance to this row. The created cell is returned for further configuration.
        Returns:
        the created cell
      • addHeaderCells

        public void addHeaderCells​(com.vaadin.flow.component.Component... components)
        Wrapps given components into header cells and adds them to this instance.
        Parameters:
        components - cells to add
      • addHeaderCells

        public void addHeaderCells​(String... contents)
        Adds header cells with given string content
        Parameters:
        contents - strings to add to row
      • addDataCells

        public TableDataCell[] addDataCells​(int cells)
        Adds multiple data cells to this instance based on the given integer (must be greater than 0). The created cells are returned as an array, that can be used for further configuration.
        Parameters:
        cells - amount of cells to add
        Returns:
        created cell objects
      • addHeaderCells

        public TableHeaderCell[] addHeaderCells​(int cells)
        Adds multiple header cells to this instance based on the given integer (must be greater than 0). The created cells are returned as an array, that can be used for further configuration.
        Parameters:
        cells - amount of cells to add
        Returns:
        created cell objects
      • addCells

        public void addCells​(TableCell... cells)
        Adds the given cells to this instance.
        Parameters:
        cells - cells to add
      • addCells

        public void addCells​(com.vaadin.flow.component.Component... components)
        Wrapps given components into table cells and adds them to this instance.
        Parameters:
        components - cells to add
      • addCells

        public void addCells​(String... contents)
        Adds data cells with given string content
        Parameters:
        contents - strings to add to row
      • removeCells

        public void removeCells​(TableCell... cells)
        Removes the given cells from this instance. Cells, that are not child of this instance, will lead to an exception.
        Parameters:
        cells - cells to remove
      • removeCell

        public void removeCell​(int index)
        Removes the cell with the given index. Noop, if no cell has been found for that index.
        Parameters:
        index - index to remove
      • removeAllCells

        public void removeAllCells()
        Removes all cells from this instance.
      • removeDataCell

        public void removeDataCell​(int dataCellIndex)
        Removes the data cell with the given index. Noop, if no data cell has been found for that index.

        The index is expected to relate on data cells only, which means, that any header cells are ignores / not counted. For instance in a row with the two cells (header, data), this method expects a 0 to map the data cell instance (whereas getCell(int) would map it with 1).
        Parameters:
        dataCellIndex - index to remove
      • removeAllDataCells

        public void removeAllDataCells()
        Removes all data cells from this instance. Header cells are kept. Noop if the row is empty or contains only header cells.
      • removeHeaderCell

        public void removeHeaderCell​(int headerCellIndex)
        Removes the header cell with the given index. Noop, if no header cell has been found for that index.

        The index is expected to relate on header cells only, which means, that any header cells are ignores / not counted. For instance in a row with the two cells (data, header), this method expects a 0 to map the header cell instance (whereas getCell(int) would map it with 1).
        Parameters:
        headerCellIndex - index to remove
      • removeAllHeaderCells

        public void removeAllHeaderCells()
        Removes all header cells from this instance. Data cells are kept. Noop if the row is empty or contains only data cells.
      • getCells

        public List<TableCell> getCells()
        Returns all cells of this row as a list. Empty when this row has no cells.
        Returns:
        cells
      • getDataCells

        public List<TableDataCell> getDataCells()
        Returns all data cells of this row as a list. Returns an empty list, if this row is empty or only contains header cells.
        Returns:
        data cells
      • getHeaderCells

        public List<TableHeaderCell> getHeaderCells()
        Returns all header cells of this row as a list. Returns an empty list, if this row is empty or only contains data cells.
        Returns:
        header cells
      • getCell

        public Optional<TableCell> getCell​(int index)
        Returns the cell with the given index or an empty optional, if the index is out of bounds.
        Parameters:
        index - index
        Returns:
        cell or empty
      • getHeaderCell

        public Optional<TableHeaderCell> getHeaderCell​(int headerCellIndex)
        Returns the header cell with the given index or an empty optional, if the index is out of bounds or if no header cell has been found for that index.

        The index is expected to relate on header cells only, which means, that any header cells are ignores / not counted. For instance in a row with the two cells (data, header), this method expects a 0 to map the header cell instance (whereas getCell(int) would map it with 1).
        Parameters:
        headerCellIndex - index
        Returns:
        cell or empty
      • getDataCell

        public Optional<TableDataCell> getDataCell​(int dataCellIndex)
        Returns the data cell with the given index or an empty optional, if the index is out of bounds or if no data cell has been found for that index.

        The index is expected to relate on data cells only, which means, that any data cells are ignores / not counted. For instance in a row with the two cells (header, data), this method expects a 0 to map the data cell instance (whereas getCell(int) would map it with 1).
        Parameters:
        dataCellIndex - index
        Returns:
        cell or empty
      • streamCells

        public Stream<TableCell> streamCells()
        Returns all cells of this row as a stream. Empty when this row has no cells.
        Returns:
        cells
      • streamDataCells

        public Stream<TableDataCell> streamDataCells()
        Returns all data cells of this row as a stream. Returns an empty stream, if this row is empty or only contains header cells.
        Returns:
        data cells
      • streamHeaderCells

        public Stream<TableHeaderCell> streamHeaderCells()
        Returns all header cells of this row as a stream. Returns an empty stream, if this row is empty or only contains data cells.
        Returns:
        header cells