Class TreeTableSorter

  • All Implemented Interfaces:
    TreeTableModel, TreeModel

    public class TreeTableSorter
    extends AbstractTreeTableModel
    Allow users to sort TreeTables. Sibling nodes are sorted with respect to one another. Sibling nodes must always be displayed next to one another. It would be nice to allow different sorting directives based on tree depth but this is not currently possible. Requires commons-colletions.

    See Also:
    JTreeTable, ResultSet
    • Constructor Detail

    • Method Detail

      • getSortDirectives

        public Map<Integer,​Boolean> getSortDirectives()
        Map from column index to sort directive. Updating this map will likely cause TreeTableModel events to be fired due to resorting. If performance is a concern, it is better to call bulk modification methods ('addAll', 'clear', 'removeAll') rather than making repeated calls to 'add' and 'remove'. This map is backed by a LinkedHashMap so order is maintained during additions. null not permitted.
      • getColumnCount

        public int getColumnCount()
        Description copied from interface: TreeTableModel
        Returns the number of available columns.
      • getColumnName

        public String getColumnName​(int pCol)
        Description copied from interface: TreeTableModel
        Returns the name for column number column.
      • getChildCount

        public int getChildCount​(Object pParent)
      • getValueAt

        public Object getValueAt​(Object pNode,
                                 int pCol)
        Description copied from interface: TreeTableModel
        Returns the value to be displayed for node node, at column number column.
      • getChild

        public Object getChild​(Object pParent,
                               int pIdx)
      • viewIndex

        public int viewIndex​(Object pParent,
                             int pModelIdx)
        Get index from underlying model.
      • getOldToNewIndexMap

        public org.apache.commons.collections4.BidiMap<Integer,​Integer> getOldToNewIndexMap​(Object pNode)
        Map from underlying model index to view index.
      • setTableHeader

        public void setTableHeader​(JTableHeader pTableHeader)
      • setColumnComparator

        public void setColumnComparator​(Class<?> pType,
                                        Comparator<?> pComparator)
      • getComparator

        protected Comparator getComparator​(int pCol)
      • main

        public static void main​(String[] pArgs)
        Opens a window with sample tree and rearrangement buttons.