Class ListSortUI
- java.lang.Object
-
- org.jdesktop.swingx.plaf.basic.core.ListSortUI
-
public final class ListSortUI extends java.lang.Object
ListSortUI provides support for managing the synchronization between RowSorter, SelectionModel and ListModel if a JXList is sortable.This implementation is an adaption of JTable.SortManager fit to the needs of a ListUI. In contrast to JTable tradition, the ui delegate has full control about listening to model/selection changes and updating the list accordingly. So it's role is that of a helper to the ui-delgate (vs. as a helper of the JTable). It's still up to the ListUI itself to listen to model/selection and propagate the notification to this class, if a sorter is installed, but still do the usual updates (layout, repaint) itself. On the other hand, listening to the sorter and updating list state accordingly is completely done by this.
-
-
Constructor Summary
Constructors Constructor Description ListSortUI(JXList list, javax.swing.RowSorter<? extends javax.swing.ListModel> sorter)
Intanstiates a SortUI on the list which has the given RowSorter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.event.RowSorterListener
createRowSorterListener()
Creates and returns a RowSorterListener.void
dispose()
Disposes any resources used by this SortManager.void
modelChanged(javax.swing.event.ListDataEvent e)
Called after notification from ListModel.protected void
sortedChanged(javax.swing.event.RowSorterEvent e)
Called after notification from RowSorter.void
viewSelectionChanged(javax.swing.event.ListSelectionEvent e)
Called after notification from selectionModel.
-
-
-
Constructor Detail
-
ListSortUI
public ListSortUI(JXList list, javax.swing.RowSorter<? extends javax.swing.ListModel> sorter)
Intanstiates a SortUI on the list which has the given RowSorter.- Parameters:
list
- the list to control, must not be nullsorter
- the rowSorter of the list, must not be null- Throws:
java.lang.NullPointerException
- if either the list or the sorter is nulljava.lang.IllegalStateException
- if the sorter is not the sorter installed on the list
-
-
Method Detail
-
dispose
public void dispose()
Disposes any resources used by this SortManager. Note: this instance must not be used after dispose!
-
modelChanged
public void modelChanged(javax.swing.event.ListDataEvent e)
Called after notification from ListModel.- Parameters:
e
- the change event from the listModel.
-
viewSelectionChanged
public void viewSelectionChanged(javax.swing.event.ListSelectionEvent e)
Called after notification from selectionModel. Invoked when the selection, on the view, has changed.
-
sortedChanged
protected void sortedChanged(javax.swing.event.RowSorterEvent e)
Called after notification from RowSorter.- Parameters:
e
- RowSorter event of type SORTED.
-
createRowSorterListener
protected javax.swing.event.RowSorterListener createRowSorterListener()
Creates and returns a RowSorterListener. This implementation calls sortedChanged if the event is of type SORTED.- Returns:
- rowSorterListener to install on sorter.
-
-