Class SpreadsheetFilterTable

  • All Implemented Interfaces:
    Serializable

    public class SpreadsheetFilterTable
    extends SpreadsheetTable
    Represents a "table" inside a spreadsheet, that has filters ( SpreadsheetFilter) inside the table's headers' pop-up buttons.

    Does simple filtering by hiding the filtered rows from the table (as in Excel).

    Automatically generates "item filters" (ItemFilter) for each column.

    Has a "Clear Filters" button inside the PopupButtons pop-up, that clears all the filters for that column (contained within the same pop-up).

    Author:
    Vaadin Ltd.
    See Also:
    Serialized Form
    • Constructor Detail

      • SpreadsheetFilterTable

        public SpreadsheetFilterTable​(Spreadsheet spreadsheet,
                                      org.apache.poi.ss.util.CellRangeAddress fullTableRegion)
        Creates a new filter table for the given spreadsheet component, its active sheet (Spreadsheet.getActiveSheet() and region. Pop-up buttons and content (filters) are created.
        Parameters:
        spreadsheet - Target Spreadsheet
        fullTableRegion - Cell range to include in the table
      • SpreadsheetFilterTable

        public SpreadsheetFilterTable​(Spreadsheet spreadsheet,
                                      org.apache.poi.ss.usermodel.Sheet sheet,
                                      org.apache.poi.ss.util.CellRangeAddress fullTableRegion)
        Creates a new filter table for the given spreadsheet component, sheet and region. If the component is currently displaying the sheet that the table belongs to, pop-up buttons and content (filters) are created.
        Parameters:
        spreadsheet - Target Spreadsheet
        sheet - Target sheet within the Spreadsheet
        fullTableRegion - Cell range to include in the table
    • Method Detail

      • reload

        public void reload()
        Reloads all the pop-up buttons and the pop-up contents (filters).

        If the pop-up buttons and filters have been cleared (clear() has been called) they will be recreated with "empty" filters. Otherwise the existing pop-up buttons are just added to the component again.

        Overrides:
        reload in class SpreadsheetTable
      • clear

        public void clear()
        Clears all the pop-up buttons and their contents (filters).

        If this Table is reloaded after this method has been called, the filters will have cleared their states.

        Overrides:
        clear in class SpreadsheetTable
      • clearAllFilters

        public void clearAllFilters()
        Clears all filters for this table. Does not remove the actual filter components.
      • initClearAllButtons

        protected void initClearAllButtons()
        Creates the "Clear filters" buttons for the pop-ups.
      • initFilters

        protected void initFilters()
        Creates all filters for this table. Override this in an extending class for adding filters on class construction.
      • initItemFilters

        protected void initItemFilters()
        Creates item filters for this table.
      • createClearButton

        protected Button createClearButton()
        Creates a "Clear filters" button. It has the "clear-filters-button" class name.
        Returns:
        Button for clearing the filters
      • getFilteringRegion

        public org.apache.poi.ss.util.CellRangeAddress getFilteringRegion()
        Gets the filtering region, CellRangeAddress for this table.
        Returns:
        The filtering region
      • onFiltersUpdated

        public void onFiltersUpdated()
        Called when one of the filters (SpreadsheetFilter) has been updated, and the sheet (SpreadsheetTable.getSheet()) and component ( SpreadsheetTable.getSpreadsheet()) need to be updated to reflect to the filters' values.

        NOTE: The default ItemFilters will call this method automatically on change. You only need to call this method when you have implemented and added your own SpreadsheetFilter.

      • registerFilter

        public void registerFilter​(PopupButton popupButton,
                                   SpreadsheetFilter filter)
        Registers a new filter to this filter table and adds it inside the given pop-up button.

        NOTE: Does not apply updates, if the registered filter is filtering some rows, onFiltersUpdated() should be called.

        Parameters:
        popupButton - The pop-up button this filter is added to
        filter - The filter to apply
      • unRegisterFilter

        public void unRegisterFilter​(PopupButton popupButton,
                                     SpreadsheetFilter filter)
        Unregisters the filter from this filter table and removes it from the given pop-up button.
        Parameters:
        popupButton - The pop-up button this filter is removed from
        filter - The filter to remove