Class Table

    • Field Detail

      • DISPLAY_ROW_COUNT_PROPERTY

        public static final java.lang.String DISPLAY_ROW_COUNT_PROPERTY
        The display row count bound property.
      • DISPLAY_ROW_START_INDEX_PROPERTY

        public static final java.lang.String DISPLAY_ROW_START_INDEX_PROPERTY
        The display row start index bound property.
      • updatePrototypesPropertyChangeListener

        protected final java.beans.PropertyChangeListener updatePrototypesPropertyChangeListener
        The property change listener that updates prototype properties.
    • Constructor Detail

      • Table

        public Table​(java.lang.Class<C> valueClass,
                     java.lang.String... columnNames)
        Value class and column names constructor with a default data model. Default cell representation strategies will be installed for the value classes of the indicated columns.
        Type Parameters:
        C - The type of values in all the cells in the table.
        Parameters:
        valueClass - The class indicating the type of values held in the model.
        columnNames - The names to serve as label headers for the columns.
        Throws:
        java.lang.NullPointerException - if the given value class is null.
      • Table

        public Table​(TableColumnModel<?>... columns)
        Columns constructor with a default data model. Default cell representation strategies will be installed for the value classes of the given columns.
        Parameters:
        columns - The models representing the table columns.
      • Table

        public Table​(java.lang.Class<C> valueClass,
                     C[][] rowValues,
                     java.lang.String... columnNames)
        Value class, table data, and column names constructor with a default data model. Default cell representation strategies will be installed for the value classes of the indicated columns.
        Type Parameters:
        C - The type of values in all the cells in the table.
        Parameters:
        valueClass - The class indicating the type of values held in the model.
        rowValues - The two-dimensional list of values, where the first index represents the row and the second represents the column, or null if no default values should be given.
        columnNames - The names to serve as label headers for the columns.
        Throws:
        java.lang.NullPointerException - if the given value class is null.
        java.lang.IllegalArgumentException - if the given number of columns does not equal the number of columns in any given data row.
        java.lang.ClassCastException - if one of the values in a row is not compatible with the type of its column.
      • Table

        public Table​(java.lang.Object[][] rowValues,
                     TableColumnModel<?>... columns)
        Table data and columns constructor with a default data model. Default cell representation strategies will be installed for the value classes of the given columns.
        Parameters:
        rowValues - The two-dimensional list of values, where the first index represents the row and the second represents the column, or null if no default values should be given.
        columns - The models representing the table columns.
        Throws:
        java.lang.IllegalArgumentException - if the given number of columns does not equal the number of columns in any given data row.
        java.lang.ClassCastException - if one of the values in a row is not compatible with the type of its column.
      • Table

        public Table​(TableModel tableModel)
        Table model constructor. Default cell representation strategies will be installed for the value classes of all the model's columns.
        Parameters:
        tableModel - The component data model.
        Throws:
        java.lang.NullPointerException - if the given table model is null.
    • Method Detail

      • getTableModel

        protected TableModel getTableModel()
        Returns:
        The table model used by this component.
      • getFirstActionPrototype

        public ActionPrototype getFirstActionPrototype()
        Returns:
        The prototype for the first action.
      • getPreviousActionPrototype

        public ActionPrototype getPreviousActionPrototype()
        Returns:
        The prototype for the previous action.
      • getNextActionPrototype

        public ActionPrototype getNextActionPrototype()
        Returns:
        The prototype for the next action.
      • getLastActionPrototype

        public ActionPrototype getLastActionPrototype()
        Returns:
        The prototype for the last action.
      • getDisplayRowCount

        public int getDisplayRowCount()
        Returns:
        The number of rows to display at one time, or -1 the row count is not restricted.
      • setDisplayRowCount

        public void setDisplayRowCount​(int newDisplayRowCount)
        Sets the number of rows to display at one time. This is a bound property of type Integer.
        Parameters:
        newDisplayRowCount - The number of rows to display at one time, or -1 the row count is not restricted.
        See Also:
        DISPLAY_ROW_COUNT_PROPERTY
      • getDisplayRowStartIndex

        public int getDisplayRowStartIndex()
        Returns:
        The index of the first row to display.
      • setDisplayRowStartIndex

        public void setDisplayRowStartIndex​(int newDisplayRowStartIndex)
        Sets the index of the first row to display. This is a bound property of type Integer.
        Parameters:
        newDisplayRowStartIndex - The index of the first row to display.
        Throws:
        java.lang.IndexOutOfBoundsException - if the given index is less than zero.
        See Also:
        DISPLAY_ROW_START_INDEX_PROPERTY
      • isEditable

        public boolean isEditable()
        Specified by:
        isEditable in interface EditComponent
        Returns:
        Whether the value is editable and the component will allow the the user to change the value.
      • setEditable

        public void setEditable​(boolean newEditable)
        Description copied from interface: EditComponent
        Sets whether the value is editable and the component will allow the the user to change the value. This is a bound property of type Boolean.
        Specified by:
        setEditable in interface EditComponent
        Parameters:
        newEditable - true if the component should allow the user to change the value.
        See Also:
        EditComponent.EDITABLE_PROPERTY
      • setCellRepresentationStrategy

        public <V> Table.CellRepresentationStrategy<? super V> setCellRepresentationStrategy​(java.lang.Class<V> valueClass,
                                                                                             Table.CellRepresentationStrategy<V> cellRepresentationStrategy)
        Installs the given cell representation strategy to produce representation components for the given value class. The specified representation strategy will only be used if there is no representation strategy for a given column.
        Type Parameters:
        V - The type of value represented.
        Parameters:
        valueClass - The value class with which the strategy should be associated.
        cellRepresentationStrategy - The strategy for generating components to represent values of the given type.
        Returns:
        The representation strategy previously associated with the given value class.
        See Also:
        setCellRepresentationStrategy(TableColumnModel, CellRepresentationStrategy)
      • getCellRepresentationStrategy

        public <V> Table.CellRepresentationStrategy<? super V> getCellRepresentationStrategy​(java.lang.Class<V> valueClass)
        Returns the given cell representation strategy assigned to produce representation components for the given value class. The returned representation strategy can be overridden by a representation strategy associated with a particular column.
        Type Parameters:
        V - The type of value represented.
        Parameters:
        valueClass - The value class with which the strategy should be associated.
        Returns:
        The strategy for generating components to represent values of the given type, or null if there is no associated representation strategy.
        See Also:
        getCellRepresentationStrategy(TableColumnModel)
      • setCellRepresentationStrategy

        public <V> Table.CellRepresentationStrategy<? super V> setCellRepresentationStrategy​(TableColumnModel<V> column,
                                                                                             Table.CellRepresentationStrategy<V> cellRepresentationStrategy)
        Installs the given cell representation strategy to produce representation components for the given column. A cell representation strategy for a particular column will override a cell representation strategy registered for a given type.
        Type Parameters:
        V - The type of value the column represents.
        Parameters:
        column - The column with which the strategy should be associated.
        cellRepresentationStrategy - The strategy for generating components to represent values in the given column.
        Returns:
        The representation strategy previously associated with the given column.
        See Also:
        setCellRepresentationStrategy(Class, CellRepresentationStrategy)
      • getCellRepresentationStrategy

        public <V> Table.CellRepresentationStrategy<? super V> getCellRepresentationStrategy​(TableColumnModel<V> column)
        Returns the given cell representation strategy assigned to produce representation components for the given column. A cell representation strategy for a particular column will override a cell representation strategy registered for a given type.
        Type Parameters:
        V - The type of value the column represents.
        Parameters:
        column - The column with which the strategy should be associated.
        Returns:
        The strategy for generating components to represent values in the given column, or null if there is no associated representation strategy.
        See Also:
        getCellRepresentationStrategy(Class)
      • createTypedComponentState

        protected <T> Table.CellComponentState createTypedComponentState​(TableModel.Cell<T> cell)
        Creates a component state to represent the given object.
        Type Parameters:
        T - The type of value contained in the cell.
        Parameters:
        cell - The object with which the component state is to be associated.
        Returns:
        The component state to represent the given object.
        Throws:
        java.lang.IllegalArgumentException - if the given object is not an appropriate object for a component state to be created.
        java.lang.IllegalStateException - if there is no registered cell representation strategy appropriate for the cell.
      • getColumnUIModel

        public Table.ColumnUIModel getColumnUIModel​(TableColumnModel<?> column)
        Retrieves the UI model for the given column. If no UI model yet exists for the given column, one will be created. There is normally no need for applications to call this method directly.
        Parameters:
        column - The column for which a UI model should be returned.
        Returns:
        The UI model for the given column.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • getColumnLabelFontFamilies

        public java.util.List<java.lang.String> getColumnLabelFontFamilies​(TableColumnModel<?> column)
        Returns the label font families for a given column.
        Parameters:
        column - The column for which the label font families should be returned.
        Returns:
        The prioritized list of label font family names, or null if no label font family names have been specified.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • setColumnLabelFontFamilies

        public void setColumnLabelFontFamilies​(TableColumnModel<?> column,
                                               java.util.List<java.lang.String> newLabelFontFamilies)
        Sets the font families of the label for a given column. This is a bound property.
        Parameters:
        column - The column for which the label font families should be set.
        newLabelFontFamilies - The new prioritized list of label font family names, or null if no label font family names are specified.
        Throws:
        java.lang.NullPointerException - if the given column is null.
        See Also:
        PresentationModel.LABEL_FONT_FAMILIES_PROPERTY
      • setColumnLabelFontFamilies

        public void setColumnLabelFontFamilies​(java.util.List<java.lang.String> newLabelFontFamilies)
        Sets the font families of the labels of all columns. This is a bound property for each column.
        Parameters:
        newLabelFontFamilies - The new prioritized list of label font family names, or null if no label font family names are specified.
        See Also:
        PresentationModel.LABEL_FONT_FAMILIES_PROPERTY
      • getColumnLabelFontSize

        public Extent getColumnLabelFontSize​(TableColumnModel<?> column)
        Returns the label font size for a given column.
        Parameters:
        column - The column for which the label font size should be returned.
        Returns:
        The size of the label font from baseline to baseline, or null if no label font size has been specified.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • setColumnLabelFontSize

        public void setColumnLabelFontSize​(TableColumnModel<?> column,
                                           Extent newLabelFontSize)
        Sets the label font size of a given column. This is a bound property.
        Parameters:
        column - The column for which the label font size should be set.
        newLabelFontSize - The new size of the label font from baseline to baseline, or null there is no label font size specified.
        Throws:
        java.lang.NullPointerException - if the given column is null.
        See Also:
        PresentationModel.LABEL_FONT_SIZE_PROPERTY
      • setColumnLabelFontSize

        public void setColumnLabelFontSize​(Extent newLabelFontSize)
        Sets the label font size of all columns. This is a bound property for each column.
        Parameters:
        newLabelFontSize - The new size of the label font from baseline to baseline, or null there is no label font size specified.
        See Also:
        PresentationModel.LABEL_FONT_SIZE_PROPERTY
      • getColumnLabelFontStyle

        public FontStyle getColumnLabelFontStyle​(TableColumnModel<?> column)
        Returns the label font style for a given column.
        Parameters:
        column - The column for which the label font style should be returned.
        Returns:
        The style of the label font.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • setColumnLabelFontStyle

        public void setColumnLabelFontStyle​(TableColumnModel<?> column,
                                            FontStyle newLabelFontStyle)
        Sets the style of the label font for a given column. This is a bound property.
        Parameters:
        column - The column for which the label font size should be set.
        newLabelFontStyle - The style of the label font.
        Throws:
        java.lang.NullPointerException - if the given column and/or label font style is null.
        See Also:
        PresentationModel.LABEL_FONT_STYLE_PROPERTY
      • setColumnLabelFontStyle

        public void setColumnLabelFontStyle​(FontStyle newLabelFontStyle)
        Sets the style of the label font for all columns. This is a bound property of each column.
        Parameters:
        newLabelFontStyle - The style of the label font.
        Throws:
        java.lang.NullPointerException - if the given label font style is null.
        See Also:
        PresentationModel.LABEL_FONT_STYLE_PROPERTY
      • getColumnLabelFontWeight

        public double getColumnLabelFontWeight​(TableColumnModel<?> column)
        Returns the label font weight for a given column.
        Parameters:
        column - The column for which the label font weight should be returned.
        Returns:
        The weight of the label font relative to a normal value of 0.5.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • getColumnPaddingExtent

        public Extent getColumnPaddingExtent​(TableColumnModel<?> column,
                                             Border border)
        Returns the padding extent of the indicated column border.
        Parameters:
        column - The column for which a padding extent should be returned.
        border - The border for which a padding extent should be returned.
        Returns:
        The padding extent of the given column border.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • getColumnPaddingLineNearExtent

        public Extent getColumnPaddingLineNearExtent​(TableColumnModel<?> column)
        Returns the padding extent of the column line near page near border.
        Parameters:
        column - The column for which a padding extent should be returned.
        Returns:
        The padding extent of the given column border.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • getColumnPaddingLineFarExtent

        public Extent getColumnPaddingLineFarExtent​(TableColumnModel<?> column)
        Returns the padding extent of the column line far page near border.
        Parameters:
        column - The column for which a padding extent should be returned.
        Returns:
        The padding extent of the given column border.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • getColumnPaddingPageNearExtent

        public Extent getColumnPaddingPageNearExtent​(TableColumnModel<?> column)
        Returns the padding extent of the column line near page far border.
        Parameters:
        column - The column for which a padding extent should be returned.
        Returns:
        The padding extent of the given column border.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • getColumnPaddingPageFarExtent

        public Extent getColumnPaddingPageFarExtent​(TableColumnModel<?> column)
        Returns the padding extent of the column line far page far border.
        Parameters:
        column - The column for which a padding extent should be returned.
        Returns:
        The padding extent of the given column border.
        Throws:
        java.lang.NullPointerException - if the given column is null.
      • setColumnPaddingLineNearExtent

        public void setColumnPaddingLineNearExtent​(TableColumnModel<?> column,
                                                   Extent newPaddingExtent)
        Sets the padding extent of the column line near border. This is a bound property.
        Parameters:
        column - The column for which the padding extent should be set.
        newPaddingExtent - The padding extent.
        Throws:
        java.lang.NullPointerException - if the given column and/or padding extent is null.
        See Also:
        PresentationModel.PADDING_LINE_NEAR_EXTENT_PROPERTY
      • setColumnPaddingLineFarExtent

        public void setColumnPaddingLineFarExtent​(TableColumnModel<?> column,
                                                  Extent newPaddingExtent)
        Sets the padding extent of the column line far border. This is a bound property.
        Parameters:
        column - The column for which the padding extent should be set.
        newPaddingExtent - The padding extent, or null if the default padding extent should be used.
        Throws:
        java.lang.NullPointerException - if the given column and/or padding extent is null.
        See Also:
        PresentationModel.PADDING_LINE_FAR_EXTENT_PROPERTY
      • setColumnPaddingPageNearExtent

        public void setColumnPaddingPageNearExtent​(TableColumnModel<?> column,
                                                   Extent newPaddingExtent)
        Sets the padding extent of the column page near border. This is a bound property.
        Parameters:
        column - The column for which the padding extent should be set.
        newPaddingExtent - The padding extent, or null if the default padding extent should be used.
        Throws:
        java.lang.NullPointerException - if the given columna and/or padding extent is null.
        See Also:
        PresentationModel.PADDING_PAGE_NEAR_EXTENT_PROPERTY
      • setColumnPaddingPageFarExtent

        public void setColumnPaddingPageFarExtent​(TableColumnModel<?> column,
                                                  Extent newPaddingExtent)
        Sets the padding extent of the column page far border. This is a bound property.
        Parameters:
        column - The column for which the padding extent should be set.
        newPaddingExtent - The padding extent, or null if the default padding extent should be used.
        Throws:
        java.lang.NullPointerException - if the given column and/or padding extent is null.
        See Also:
        PresentationModel.PADDING_PAGE_FAR_EXTENT_PROPERTY
      • setColumnPaddingLineNearExtent

        public void setColumnPaddingLineNearExtent​(Extent newPaddingExtent)
        Sets the padding extent of the line near border of all columns. This is a bound property.
        Parameters:
        newPaddingExtent - The padding extent.
        Throws:
        java.lang.NullPointerException - if the given padding extent is null.
        See Also:
        PresentationModel.PADDING_LINE_NEAR_EXTENT_PROPERTY
      • setColumnPaddingLineFarExtent

        public void setColumnPaddingLineFarExtent​(Extent newPaddingExtent)
        Sets the padding extent of the line far border of all columns. This is a bound property.
        Parameters:
        newPaddingExtent - The padding extent, or null if the default padding extent should be used.
        Throws:
        java.lang.NullPointerException - if the given padding extent is null.
        See Also:
        PresentationModel.PADDING_LINE_FAR_EXTENT_PROPERTY
      • setColumnPaddingPageNearExtent

        public void setColumnPaddingPageNearExtent​(Extent newPaddingExtent)
        Sets the padding extent of the page near border of all columns. This is a bound property.
        Parameters:
        newPaddingExtent - The padding extent, or null if the default padding extent should be used.
        Throws:
        java.lang.NullPointerException - if the given padding extent is null.
        See Also:
        PresentationModel.PADDING_PAGE_NEAR_EXTENT_PROPERTY
      • setColumnPaddingPageFarExtent

        public void setColumnPaddingPageFarExtent​(Extent newPaddingExtent)
        Sets the padding extent of the page far border of all columns. This is a bound property.
        Parameters:
        newPaddingExtent - The padding extent, or null if the default padding extent should be used.
        Throws:
        java.lang.NullPointerException - if the given padding extent is null.
        See Also:
        PresentationModel.PADDING_PAGE_FAR_EXTENT_PROPERTY
      • updatePrototypes

        protected void updatePrototypes()
        Updates the state of the prototypes, such as previous and next.
      • goFirst

        public void goFirst()
        Goes to the first set of table rows.
      • goPrevious

        public void goPrevious()
        Goes to the previous set of table rows if the display row count is restricted. If the display row count is not restricted and the row start index is greater than zero, it is reset to zero.
        See Also:
        getDisplayRowStartIndex(), getDisplayRowCount()
      • goNext

        public void goNext()
        Goes to the next set of table rows if the display row count is restricted. If the display row count is not restricted, or there are no rows, nothing occurs.
        See Also:
        getDisplayRowStartIndex(), getDisplayRowCount()
      • getColumnIndex

        public int getColumnIndex​(TableColumnModel<?> column)
        Description copied from interface: TableModel
        Determines the logical index of the given table column.
        Specified by:
        getColumnIndex in interface TableModel
        Parameters:
        column - One of the table columns.
        Returns:
        The zero-based logical index of the column within the table, or -1 if the column is not one of the model's columns.
      • getColumns

        public java.util.List<TableColumnModel<?>> getColumns()
        Specified by:
        getColumns in interface TableModel
        Returns:
        A read-only list of table columns in physical order.
      • getRowCount

        public int getRowCount()
        Specified by:
        getRowCount in interface TableModel
        Returns:
        The number of rows in this table.
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface TableModel
        Returns:
        The number of columns in this table.
      • getCellValue

        public <C> C getCellValue​(TableModel.Cell<C> cell)
        Description copied from interface: TableModel
        Returns the cell value for the given cell. This method delegates to TableModel.getCellValue(int, TableColumnModel).
        Specified by:
        getCellValue in interface TableModel
        Type Parameters:
        C - The type of cell value.
        Parameters:
        cell - The cell containing the row index and column information.
        Returns:
        The value in the cell at the given row and column, or null if there is no value in that cell.
      • getCellValue

        public <C> C getCellValue​(int rowIndex,
                                  TableColumnModel<C> column)
        Description copied from interface: TableModel
        Returns the cell value at the given row and column.
        Specified by:
        getCellValue in interface TableModel
        Type Parameters:
        C - The type of cell values in the given column.
        Parameters:
        rowIndex - The zero-based row index.
        column - The column for which a value should be returned.
        Returns:
        The value in the cell at the given row and column, or null if there is no value in that cell.
      • setCellValue

        public <C> void setCellValue​(TableModel.Cell<C> cell,
                                     C newCellValue)
        Description copied from interface: TableModel
        Sets the cell value for the given cell. This method delegates to TableModel.setCellValue(int, TableColumnModel, Object).
        Specified by:
        setCellValue in interface TableModel
        Type Parameters:
        C - The type of cell value.
        Parameters:
        cell - The cell containing the row index and column information.
        newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
      • setCellValue

        public <C> void setCellValue​(int rowIndex,
                                     TableColumnModel<C> column,
                                     C newCellValue)
        Description copied from interface: TableModel
        Sets the cell value at the given row and column.
        Specified by:
        setCellValue in interface TableModel
        Type Parameters:
        C - The type of cell values in the given column.
        Parameters:
        rowIndex - The zero-based row index.
        column - The column for which a value should be returned.
        newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
      • fireEdited

        protected void fireEdited​(EditEvent editEvent)
        Fires a given edit event to all registered edit listeners.
        Parameters:
        editEvent - The edit event to fire.