Tree Table Model (ITreeTableModel)

There are at least two different ways to look at a tree table. The first one sees a tree table as an extension of a table component where the table gets extended with the capability to display a tree structure in one of its columns. The second one starts with a tree component and extends it with the capability of displaying columns. FlexGantt uses the second approach. As a result the ITreeTableModel is an extension of the standard TreeModel found in Swing. The following methods are added by the ITreeTableModel in order to deal with columns:

void ITreeTableModel.setKey(T node, Object key);
Object ITreeTableModel.getKey(T node);
void ITreeTableModel.setColumnValue(T node, Object value, int modelIndex);
Object ITreeTableModel.getColumnValue(T node, int modelIndex);

These methods allow the application to specify values for the key columns and the value columns. The key column is the column that displays the object hierarchy as a tree. The value columns are standard columns responsible for displaying values of a node. More information on key and value columns can be found in the description of the calendar model. The tree table model also contains a method, which returns a model object that can be used to control the appearance of the row header. The row header gets displayed to the left of the tree table and usually displays row numbers. However, the row header uses renderers to visualize each row number. The lookup of the renderer can be controlled via a row header value object that can be returned by the model.

Object ITreeTableModel.getRowHeaderValue(T node);
RowHeader.setRowHeaderRenderer(Class headerValueType, IRowHeaderRenderer renderer);

The tree table model supports special event listeners of type ITreeTableModelListener, which is an extension of the standard TreeModelListener interface. It adds callback methods that get invoked when the key of the values of a tree table node changes.

void ITreeTableModelListener.treeNodeKeyChanged(TreeTableModelEvent evt);
void ITreeTableModelListener.treeNodeValueChanged(TreeTableModelEvent evt);

The last feature supported by the tree table model is the capability to sort. Sorting can be performed on multiple columns at the same time, each column in ascending or descending order.

void ITreeTableModel.sort(T node, int[] modelIndices, boolean[] sortDirections);