Interface TableHandler

  • All Superinterfaces:
    ComponentHandler<Object>

    public interface TableHandler
    extends ComponentHandler<Object>

    A specialized ComponentHandler interface dealing with specific functionality provided by tables.

    Tables provide some special functionality that is not covered by the default ComponentHandler interface. So this extended interface was introduced. It provides access to the selected index (or indices in multi-selection mode), or allows sending change notifications if the data of the table's model has changed.

    Version:
    $Id: TableHandler.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Method Detail

      • getSelectedIndex

        int getSelectedIndex()
        Returns the index of the selected row. This method is applicable in single selection mode. The returned index is 0-based. A return value of -1 indicates that no row is selected.
        Returns:
        the index of the selected row
      • setSelectedIndex

        void setSelectedIndex​(int rowIdx)
        Sets the index of the selected row. In single selection mode this method can be used to select a row.
        Parameters:
        rowIdx - the (0-based) index of the row to select
      • getSelectedIndices

        int[] getSelectedIndices()
        Returns an array with the indices of the selected rows. This method is applicable in multi selection mode. It works like getSelectedIndex(), but multiple indices can be returned.
        Returns:
        an array with the indices of the selected rows (never null)
      • setSelectedIndices

        void setSelectedIndices​(int[] rowIndices)
        Sets the indices of the selected rows in multi selection mode. With this method an arbitrary number of rows can be selected at once.
        Parameters:
        rowIndices - an array with the indices of the selected rows (must not be null; use clearSelection() for clearing any selected rows)
      • clearSelection

        void clearSelection()
        Clears the table's selection. This method can be used in both single and multi selection mode for removing any selection.
      • tableDataChanged

        void tableDataChanged()
        Notifies the table about an unspecific change in the data of its model. When some properties of the beans that form the table's data model are changed, the table is not able to pick up these changes automatically. Instead it has to be notified that something has changed, which will eventually cause a redraw operation. This is the most unspecific method for change notifications. It simply says that something in the model's data has changed. The table will have to redraw itself to stay in sync with the model's data. If the change can be described in a more precise way, it will be probably more efficient to use one of the other change notification methods.
      • rowsInserted

        void rowsInserted​(int startIdx,
                          int endIdx)
        Notifies the table that new rows have been inserted. This method can be called if objects have been added to the table's model. It works like tableDataChanged(), but will probably be more efficient because the table only needs to be redrawn if necessary.
        Parameters:
        startIdx - the start index of the newly added rows
        endIdx - the end index of the newly added rows (inclusive)
        See Also:
        tableDataChanged()
      • rowsDeleted

        void rowsDeleted​(int startIdx,
                         int endIdx)
        Notifies the table that a number of rows has been deleted. This method can be called if some objects have been deleted from the table's model. It works like tableDataChanged(), but will probably be more efficient because the table only needs to be redrawn if necessary.
        Parameters:
        startIdx - the index of the first affected row
        endIdx - the index of the last affected row (inclusive)
      • rowsUpdated

        void rowsUpdated​(int startIdx,
                         int endIdx)
        Notifies the table that a number of rows has been modified. This method can be called if some data objects of the table's model have been changed. It works like tableDataChanged(), but will probably be more efficient because the table only needs to be redrawn if necessary.
        Parameters:
        startIdx - the index of the first affected row
        endIdx - the index of the last affected row (inclusive)
      • getModel

        List<Object> getModel()
        Returns the underlying model of this table. This is a list that contains beans representing the single rows of the table.
        Returns:
        the model serving as the model of this table
      • getSelectionBackground

        Color getSelectionBackground()
        Returns the current background color of the selection.
        Returns:
        the selection background color
      • setSelectionBackground

        void setSelectionBackground​(Color c)
        Sets the background color for the selection.
        Parameters:
        c - the selection background color
      • getSelectionForeground

        Color getSelectionForeground()
        Returns the current foreground color of the selection.
        Returns:
        the selection foreground color
      • setSelectionForeground

        void setSelectionForeground​(Color c)
        Sets the foreground color for the selection.
        Parameters:
        c - the selection foreground color