com.dlsc.flexgantt.model.treetable

## Class TreeTableColumn<T>

- java.lang.Object
- - com.dlsc.flexgantt.util.NamedObject
  - - com.dlsc.flexgantt.model.treetable.TreeTableColumn<T>

- Type Parameters:
    `T` - the object type of the header value
  All Implemented Interfaces:
    INamedObject, Comparable<INamedObject>
  Direct Known Subclasses:
    KeyColumn

      public class TreeTableColumn<T>
      extends NamedObject

  A tree table column encapsulates all information required in order to render a header for the column, to control the user interaction with the column (e.g. sorting), and to assist in the lookup of the appropriate cell editors and renderers. Columns can be added to, removed from, or inserted into a column model. Each column has a name. Each column can also have an optional header value object, which can be used by a column header renderer to draw the column's header. Each column also has a model index that is used to retrieve values from a tree table model. The name of a column is used in various other UI controls (column chooser, popup menu).
  Since:
    1.0
  Version:
    $Revision: 1.18 $
  Author:
    Dirk Lemmermann
  See Also:
    `IColumnModel`, `KeyColumn`, `IColumnHeaderRenderer`, `ITreeTableModel.getColumnValue(Object, int)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PROPERTY_COLUMN_CLASS` A property constant used for property change events that get fired when the column class of the column gets changed.
    `static String` | `PROPERTY_HEADER_VALUE` A property constant used for property change events that get fired when the header value of the column gets changed.
    `static String` | `PROPERTY_MAX_WIDTH` A property constant used for property change events that get fired when the maximum width of the column gets changed.
    `static String` | `PROPERTY_MIN_WIDTH` A property constant used for property change events that get fired when the minimum width of the column gets changed.
    `static String` | `PROPERTY_MODEL_INDEX` A property constant used for property change events that get fired when the model index of the column gets changed.
    `static String` | `PROPERTY_WIDTH` A property constant used for property change events that get fired when the width of the column gets changed.

    - ### Fields inherited from class com.dlsc.flexgantt.util.NamedObject

      `PROPERTY_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TreeTableColumn(String name, Class columnClass)` Constructs a new tree table column.
    `TreeTableColumn(String name, Class columnClass, int modelIndex)` Constructs a new tree table column.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ITreeTableCellRenderer` | `getCellRenderer()` Returns the cell renderer used for values in this column.
    `Class` | `getColumnClass()` Returns the object type of the data shown in the column.
    `T` | `getHeaderValue()` Returns the object that represents the value used for the header renderer.
    `int` | `getMaximumWidth()` Returns the column's maximum width.
    `int` | `getMinimumWidth()` Returns the minimum width of the column.
    `int` | `getModelIndex()` Returns the column's model index which is independent of the column's current position within the tree table.
    `SortDirection[]` | `getSupportedSortDirections()` Returns the sort directions that are supported by the tree table header.
    `int` | `getWidth()` Returns the current width of the column.
    `boolean` | `isSortable()` Determines if the column is sortable at all, when it supports `SortDirection.ASCENDING` or `SortDirection.DESCENDING`.
    `boolean` | `isSupported(SortDirection direction)` Determines if the given sort direction is supported by the tree table header.
    `void` | `setCellRenderer(ITreeTableCellRenderer renderer)` /** Sets the cell renderer used for values in this column.
    `void` | `setColumnClass(Class cl)` Specifies a new object type for the data shown in the column.
    `void` | `setHeaderValue(T value)` Sets a new value that will be used by a `IColumnHeaderRenderer` to draw a header for the column.
    `void` | `setMaximumWidth(int maxWidth)` Sets a new maximum width on the column.
    `void` | `setMinimumWidth(int minWidth)` Sets a new minimum width on the column.
    `void` | `setModelIndex(int index)` Specifies a new model index represented by the column.
    `void` | `setSupportedSortDirections(SortDirection[] directions)` Sets the sort directions that are supported by the tree table header.
    `void` | `setWidth(int width)` Sets the preferred width of the column.
    `String` | `toString()` Returns the result of `headerValue.toString()`.

    - ### Methods inherited from class com.dlsc.flexgantt.util.NamedObject

      `addPropertyChangeListener, compareTo, getChangeSupport, getName, removePropertyChangeListener, setName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### PROPERTY_WIDTH

          public static final String PROPERTY_WIDTH

      A property constant used for property change events that get fired when the width of the column gets changed.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### PROPERTY_HEADER_VALUE

          public static final String PROPERTY_HEADER_VALUE

      A property constant used for property change events that get fired when the header value of the column gets changed.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### PROPERTY_MIN_WIDTH

          public static final String PROPERTY_MIN_WIDTH

      A property constant used for property change events that get fired when the minimum width of the column gets changed.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### PROPERTY_MAX_WIDTH

          public static final String PROPERTY_MAX_WIDTH

      A property constant used for property change events that get fired when the maximum width of the column gets changed.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### PROPERTY_COLUMN_CLASS

          public static final String PROPERTY_COLUMN_CLASS

      A property constant used for property change events that get fired when the column class of the column gets changed.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### PROPERTY_MODEL_INDEX

          public static final String PROPERTY_MODEL_INDEX

      A property constant used for property change events that get fired when the model index of the column gets changed.
      Since:
        1.0
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TreeTableColumn

          public TreeTableColumn(String name,
                                 Class columnClass,
                                 int modelIndex)

      Constructs a new tree table column.
      Parameters:
        `name` - the name of the column (used for sorting and in menus)
        `columnClass` - the object type of the objects shown in the column (used for looking up the correct editor and renderer for cells where no value can be found)
        `modelIndex` - the index of the data in the tree table model
      Since:
        1.0

    - #### TreeTableColumn

          public TreeTableColumn(String name,
                                 Class columnClass)

      Constructs a new tree table column.
      Parameters:
        `name` - the name of the column (used for sorting and in menus)
        `columnClass` - the object type of the objects shown in the column (used for looking up the correct editor and renderer for cells where no value can be found)
      Since:
        1.0

  - ### Method Detail

    - #### getHeaderValue

          public T getHeaderValue()

      Returns the object that represents the value used for the header renderer.
      Returns:
        the header value (used for `IColumnHeaderRenderer`
      Since:
        1.0

    - #### setHeaderValue

          public void setHeaderValue(T value)

      Sets a new value that will be used by a `IColumnHeaderRenderer` to draw a header for the column.
      Parameters:
        `value` - the new value used for rendering the header of the column
      Since:
        1.0

    - #### isSortable

          public boolean isSortable()

      Determines if the column is sortable at all, when it supports `SortDirection.ASCENDING` or `SortDirection.DESCENDING`.
      Returns:
        TRUE if the column can be sorted (independent of asending or descending direction)
      Since:
        1.0
      See Also:
        `isSupported(SortDirection)`

    - #### getModelIndex

          public int getModelIndex()

      Returns the column's model index which is independent of the column's current position within the tree table. The position might change at any time but the data will still be retrieved from the tree table model via the same index.
      Returns:
        the column's model index that is used to lookup date from a data model
      Since:
        1.0

    - #### setModelIndex

          public void setModelIndex(int index)

      Specifies a new model index represented by the column. The tree table will now retrieve different data from the tree table model.
      Parameters:
        `index` -
      Since:
        1.0

    - #### setWidth

          public void setWidth(int width)

      Sets the preferred width of the column. By default this width equals -1 which means that the preferred width of the column is equal to the preferred with of the colum header button. Calling this method will result in a property change event to be fired. The event ID is equal to `PROPERTY_WIDTH`.
      Parameters:
        `width` - the width of the column
      Since:
        1.0

    - #### getWidth

          public int getWidth()

      Returns the current width of the column.
      Returns:
        the column width
      Since:
        1.0
      See Also:
        `setWidth(int)`

    - #### toString

          public String toString()

      Returns the result of `headerValue.toString()`.
      Overrides:
        `toString` in class `NamedObject`
      Since:
        1.0

    - #### getMinimumWidth

          public int getMinimumWidth()

      Returns the minimum width of the column. The user will not be able to change the column's width to a value below the minimum width.
      Returns:
        the column's minimum width
      Since:
        1.0
      See Also:
        `setMinimumWidth(int)`

    - #### setMinimumWidth

          public void setMinimumWidth(int minWidth)

      Sets a new minimum width on the column. The user will not be able to change the column's width to a value below the minimum width. Calling this method will cause a property change event to be fired where the event ID is equal to `PROPERTY_MIN_WIDTH`.
      Parameters:
        `minWidth` - the new minimum width of the column
      Since:
        1.0
      See Also:
        `getMinimumWidth()`

    - #### getMaximumWidth

          public int getMaximumWidth()

      Returns the column's maximum width. The user will not be able to change the column's width to a value above the maximum width.
      Returns:
        the column's maximum width
      Since:
        1.0
      See Also:
        `setMaximumWidth(int)`

    - #### setMaximumWidth

          public void setMaximumWidth(int maxWidth)

      Sets a new maximum width on the column. The user will not be able to resize the column to a width that is larger than the maximum width. Calling this method will result in a property change event where the event ID is equal to `PROPERTY_MAX_WIDTH`.
      Parameters:
        `maxWidth` - the new maximum width of the column
      Since:
        1.0
      See Also:
        `getMaximumWidth()`

    - #### getColumnClass

          public Class getColumnClass()

      Returns the object type of the data shown in the column. This information is useful for looking up the appropriate cell editor / renderer even in those cases where the table cell does not have a value, yet.
      Returns:
        the object type of the column's data
      Since:
        1.0
      See Also:
        `setColumnClass(Class)`

    - #### setColumnClass

          public void setColumnClass(Class cl)

      Specifies a new object type for the data shown in the column. The type information is used to lookup cell renderers and editors for cells that do not have a value, yet. If a cell does have a value then that values type will be used for the lookup.
      Parameters:
        `cl` - the column value's object type
      Since:
        1.0
      See Also:
        `getColumnClass()`

    - #### getSupportedSortDirections

          public SortDirection[] getSupportedSortDirections()

      Returns the sort directions that are supported by the tree table header. A column can be sorted in ascending or descending order or not at all. Some applications do not support column sorting at all while others insist that columns are always sorted.
      Returns:
        the supported sort directions
      Since:
        1.0

    - #### setSupportedSortDirections

          public void setSupportedSortDirections(SortDirection[] directions)

      Sets the sort directions that are supported by the tree table header. A column can be sorted in ascending or descending order or not at all. Some applications do not support column sorting at all while others insist that columns are always sorted.
      Parameters:
        `directions` - the supported sort directions
      Since:
        1.0

    - #### isSupported

          public boolean isSupported(SortDirection direction)

      Determines if the given sort direction is supported by the tree table header.
      Parameters:
        `direction` - the sort direction to check
      Returns:
        TRUE if the given sort direction is supported by the tree table header
      Since:
        1.0

    - #### getCellRenderer

          public ITreeTableCellRenderer getCellRenderer()

      Returns the cell renderer used for values in this column. By default this value returns NULL and the tree table will use the renderers registered with it. However, only one renderer can be registered for each object type (e.g. BooleanRenderer for the Boolean type). If two columns want to show boolean values in two different ways then this is not enough. Setting a renderer directly on a column allows to override the renderer lookup that is based on object types.
      Returns:
        a cell renderer for values in this column
      Since:
        2.0

    - #### setCellRenderer

          public void setCellRenderer(ITreeTableCellRenderer renderer)

      /** Sets the cell renderer used for values in this column. By default this value returns NULL and the tree table will use the renderers registered with it. However, only one renderer can be registered for each object type (e.g. BooleanRenderer for the Boolean type). If two columns want to show boolean values in two different ways then this is not enough. Setting a renderer directly on a column allows to override the renderer lookup that is based on object types.
      Parameters:
        `renderer` - the column cell renderer
      Since:
        2.0

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.