Class AbstractTableComparatorChooser<E>

  • Direct Known Subclasses:
    TableComparatorChooser

    public abstract class AbstractTableComparatorChooser<E>
    extends java.lang.Object
    A TableComparatorChooser is a tool that allows the user to sort a table widget by clicking on the table's headers. It requires that the table has a SortedList as a source as the sorting on that list is used.
    Author:
    Kevin Maltby
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.Object MULTIPLE_COLUMN_KEYBOARD
      Emulate the sorting behaviour of SUN's TableSorter, by Philip Milne et.
      static java.lang.Object MULTIPLE_COLUMN_MOUSE
      Sort multiple columns without use of the keyboard.
      static java.lang.Object MULTIPLE_COLUMN_MOUSE_WITH_UNDO
      Sort multiple columns without use of the keyboard.
      static java.lang.Object SINGLE_COLUMN
      Emulate the sorting behaviour of Windows Explorer and Mac OS X Finder.
      protected SortedList<E> sortedList
      the sorted list to choose the comparators for
      protected java.util.Comparator<? super E> sortedListComparator
      the potentially foreign comparator associated with the sorted list
      protected ca.odell.glazedlists.impl.gui.SortingState sortingState
      manage which columns are sorted and in which order
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendComparator​(int column, int comparatorIndex, boolean reverse)
      Append the comparator specified by the column, comparator index and reverse parameters to the end of the sequence of comparators this AbstractTableComparatorChooser is sorting the SortedList by.
      void clearComparator()
      Clear all sorting state and set the SortedList to use its natural order.
      java.util.Comparator createComparatorForElement​(java.util.Comparator<E> comparatorForColumn, int column)
      Creates a Comparator that can compare list elements given a Comparator that can compare column values for the specified column.
      protected ca.odell.glazedlists.impl.gui.SortingState createSortingState()
      Returns the object which models the current sorting state of all columns in the table.
      void dispose()  
      void fromString​(java.lang.String stringEncoded)
      This class is capable of representing its own state with a String, to persist sorting state externally.
      int getColumnComparatorIndex​(int column)
      Gets the index comparator in use for the specified column.
      java.util.List<java.util.Comparator> getComparatorsForColumn​(int column)
      Gets the list of comparators for the specified column.
      java.util.List<java.lang.Integer> getSortingColumns()
      Get the columns that the TableComparatorChooser is sorting by.
      protected int getSortingStyle​(int column)
      Gets the sorting style currently applied to the specified column.
      boolean isColumnReverse​(int column)
      Gets whether the comparator in use for the specified column is reverse.
      protected void rebuildComparator()
      Updates the comparator in use and applies it to the table.
      protected void redetectComparator​(java.util.Comparator<? super E> currentComparator)
      Examines the current Comparator of the SortedList and adds icons to the table header renderers in response.
      protected void setTableFormat​(TableFormat<? super E> tableFormat)
      Adjusts the TableFormat this comparator chooser uses when selecting comparators.
      java.lang.String toString()
      Encode the current sorting state as a String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SINGLE_COLUMN

        public static final java.lang.Object SINGLE_COLUMN
        Emulate the sorting behaviour of Windows Explorer and Mac OS X Finder.

        Single clicks toggles between forward and reverse. If multiple comparators are available for a particular column, they will be cycled in order.

        At most one column can be sorted at a time.

      • MULTIPLE_COLUMN_MOUSE

        public static final java.lang.Object MULTIPLE_COLUMN_MOUSE
        Sort multiple columns without use of the keyboard. Single clicks cycle through comparators, double clicks clear all secondary sorts before performing the normal behaviour.

        This is the original sorting strategy provided by Glazed Lists, with a limitation that it is impossible to clear a sort order that is already in place. It's designed to be used with multiple columns and multiple comparators per column.

        The overall behaviour is as follows:

      • Click: sort this column. If it's already sorted, reverse the sort order. If its already reversed, sort using the column's next comparator in forward order. If there are no more comparators, go to the first comparator. If there are multiple sort columns, sort this column after those columns.
      • Double click: like a single click, but clear all sorting columns first.