Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx.sort
Interface SortController<M>

All Known Implementing Classes:
  DefaultSortController, ListSortController, TableSortController

    public interface SortController<M>

Defines the interactive sort control for sortable collection components (like JXList, JXTable). All sort gesture requests from their sort api are routed through the SortController.

This is very-much work-in-progress: while moving from ol' SwingX sorting to core jdk6 sorting we need a hook for sorting api on the view. So in terms of jdk6 classes, this is something like:

``

     SortController == DefaultRowSorter - RowSorter + XX

All methods which change sort state must respect per-controller and per-column sortable property, as follows

1. if per-controller sortable is false, do nothing
2. if per-controller sortable is true, if per-column sortable is false, do nothing
3. if both are true toggle the SortOrder of the given column

Author:
  Jesse Wilson, Jeanette Winzenburg

Method Summary
`java.util.Comparator<?>` | `getComparator(int column)` Returns the `Comparator` for the specified column.
`javax.swing.RowFilter<? super M,? super java.lang.Integer>` | `getRowFilter()` Returns the filter that determines which rows, if any, should be hidden from view.
`javax.swing.SortOrder` | `getSortOrder(int column)` Returns the sort order of the specified column.
`javax.swing.SortOrder[]` | `getSortOrderCycle()` Returns the cycle of sort orders to cycle through.
`boolean` | `getSortsOnUpdates()` Returns true if a sort should happen when the underlying model is updated; otherwise, returns false.
`StringValueProvider` | `getStringValueProvider()` Returns the StringValueProvider used to look up StringValues.
`boolean` | `isSortable()` Returns true if this controller is sortable; otherwise, false.
`boolean` | `isSortable(int column)` Returns true if the specified column is sortable.
`void` | `resetSortOrders()` Resets all interactive sorting.
`void` | `setComparator(int column, java.util.Comparator<?> comparator)` Sets the `Comparator` to use when sorting the specified column.
`void` | `setRowFilter(javax.swing.RowFilter<? super M,? super java.lang.Integer> filter)` Sets the filter that determines which rows, if any, should be hidden from the view.
`void` | `setSortable(boolean sortable)` Sets whether or not this controller is sortable.
`void` | `setSortable(int column, boolean sortable)` Sets whether or not the specified column is sortable.
`void` | `setSortOrder(int column, javax.swing.SortOrder sortOrder)` Sets the sort order of the specified column.
`void` | `setSortOrderCycle(javax.swing.SortOrder... cycle)` Sets the cycle of sort ordes to toggle through.
`void` | `setSortsOnUpdates(boolean sortsOnUpdates)` If true, specifies that a sort should happen when the underlying model is updated (`rowsUpdated` is invoked).
`void` | `setStringValueProvider(StringValueProvider provider)` Sets the StringValueProvider to look up the StringValues.
`void` | `toggleSortOrder(int column)` Reverses the sort order of the specified column.

Method Detail

### setSortable

    void setSortable(boolean sortable)

  Sets whether or not this controller is sortable.

  The default is true.

  PENDING JW: define behaviour if sortable is disabled while has sortOrders. In this case JXTable resets all sorts.

  Parameters:
    `sortable` - whether or not this controller is sortable
  See Also:
    `isSortable()`

### isSortable

    boolean isSortable()

  Returns true if this controller is sortable; otherwise, false.

  Returns:
    true if this controller is sortable
  See Also:
    `isSortable()`

### setSortable

    void setSortable(int column,
                     boolean sortable)

  Sets whether or not the specified column is sortable.

  The default is true.

  PENDING JW: define behaviour if sortable is disabled while has sortOrders. In this case JXTable removes the sort of the column.

  PENDING JW: decide whether or not this method should trigger a resort DefaultRowSorter explicitly doesn't, JXTable does.

  Parameters:
    `column` - the column to enable or disable sorting on, in terms of the underlying model
    `sortable` - whether or not the specified column is sortable
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `column` is outside the range of the model
  See Also:
    `isSortable(int)`, `toggleSortOrder(int)`, `setSortOrder(int, SortOrder)`

### isSortable

    boolean isSortable(int column)

  Returns true if the specified column is sortable.

  This returns true if both the controller's sortable property and the column's sortable property is true. Returns false if any of them is false.

  Parameters:
    `column` - the column to check sorting for, in terms of the underlying model
  Returns:
    true if the column is sortable
  Throws:
    `java.lang.IndexOutOfBoundsException` - if column is outside the range of the underlying model
  See Also:
    `isSortable(int)`

### setComparator

    void setComparator(int column,
                       java.util.Comparator<?> comparator)

  Sets the `Comparator` to use when sorting the specified column. This does not trigger a sort. If you want to sort after setting the comparator you need to explicitly invoke `sort`.

  Parameters:
    `column` - the index of the column the `Comparator` is to be used for, in terms of the underlying model
    `comparator` - the `Comparator` to use
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `column` is outside the range of the underlying model

### getComparator

    java.util.Comparator<?> getComparator(int column)

  Returns the `Comparator` for the specified column. This will return `null` if a `Comparator` has not been specified for the column.

  Parameters:
    `column` - the column to fetch the `Comparator` for, in terms of the underlying model
  Returns:
    the `Comparator` for the specified column
  Throws:
    `java.lang.IndexOutOfBoundsException` - if column is outside the range of the underlying model

### setSortOrderCycle

    void setSortOrderCycle(javax.swing.SortOrder... cycle)

  Sets the cycle of sort ordes to toggle through. Zero or more SortOrders which must not be null.

  Parameters:
    `cycle` - the SortOrders to cycle through, may be empty
  Throws:
    `java.lang.NullPointerException` - if the array or any of its elements is null

### getSortOrderCycle

    javax.swing.SortOrder[] getSortOrderCycle()

  Returns the cycle of sort orders to cycle through.

  Returns:

### setSortsOnUpdates

    void setSortsOnUpdates(boolean sortsOnUpdates)

  If true, specifies that a sort should happen when the underlying model is updated (`rowsUpdated` is invoked). For example, if this is true and the user edits an entry the location of that item in the view may change. The default is true.

  Parameters:
    `sortsOnUpdates` - whether or not to sort on update events

### getSortsOnUpdates

    boolean getSortsOnUpdates()

  Returns true if a sort should happen when the underlying model is updated; otherwise, returns false.

  Returns:
    whether or not to sort when the model is updated

### setStringValueProvider

    void setStringValueProvider(StringValueProvider provider)

  Sets the StringValueProvider to look up the StringValues. If the value is not-null, it guarantees to use it exclusively for string conversion.

  PENDING JW: this is more or less parallel to TableStringConverter. Need to think about merging somehow.

  Parameters:
    `provider` - the look up for StringValues, may be null.

### getStringValueProvider

    StringValueProvider getStringValueProvider()

  Returns the StringValueProvider used to look up StringValues.

  Returns:
    StringValueProvider used to look up StringValues, guaranteed to be not null.

### toggleSortOrder

    void toggleSortOrder(int column)

  Reverses the sort order of the specified column. The exact behaviour is up to implementations.

  Implementations must respect the per-controller and per-column-sortable property.

  Parameters:
    `column` - the model index of the column to toggle
  See Also:
    `isSortable(int)`, `isSortable()`

### setSortOrder

    void setSortOrder(int column,
                      javax.swing.SortOrder sortOrder)

  Sets the sort order of the specified column.

  Implementations must respect the per-controller and per-column-sortable property.

  Parameters:
    `column` - the model index of the column to set
    `sortOrder` - the SortOrder to set for the column
  See Also:
    `isSortable(int)`, `isSortable()`

### getSortOrder

    javax.swing.SortOrder getSortOrder(int column)

  Returns the sort order of the specified column.

  Returns:
    one of `SortOrder.ASCENDING`, `SortOrder.DESCENDING` or `SortOrder.UNSORTED`.

### resetSortOrders

    void resetSortOrders()

  Resets all interactive sorting.

  Implementations must respect the per-controller and per-column-sortable property.

### setRowFilter

    void setRowFilter(javax.swing.RowFilter<? super M,? super java.lang.Integer> filter)

  Sets the filter that determines which rows, if any, should be hidden from the view. The filter is applied before sorting. A value of `null` indicates all values from the model should be included.

  `RowFilter`'s `include` method is passed an `Entry` that wraps the underlying model. The number of columns in the `Entry` corresponds to the number of columns in the underlying model. The identifier comes from the underlying model as well.

  This method triggers a sort. PENDING JW: the "underlying model" is the ModelWrapper ... want to expose here as well? Otherwise, the second paramter doesn't make much sense.

  Parameters:
    `filter` - the filter used to determine what entries should be included

### getRowFilter

    javax.swing.RowFilter<? super M,? super java.lang.Integer> getRowFilter()

  Returns the filter that determines which rows, if any, should be hidden from view.

  Returns:
    the filter

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010. All Rights Reserved.