swingx
  1. swingx
  2. SWINGX-274

JXTable provides no mechanism to externalize sorting

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 0.9.0
    • Fix Version/s: 0.9.0
    • Component/s: Table
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Macintosh

    • Issuezilla Id:
      274

      Description

      There's no API to use JXTable's sort indicator icons without doing the sorting in JXTable itself.
      Sometimes its better to do the sorting outside of JXTable, such as:

      • for large datasets, the sorting could be performed in the database
      • for users of other frameworks, the sorting could be done in the model layer rather than in the view

      Ideally there would be a mechanism to replace the default handler for sort calls in the JXTableHeader.
      Such an API would look like this:
      class SortHandler

      { setSortColumn(int column, boolean ascending); }

      Then I could install my own SortHandler on the table and continue to leverage JXTable's indicator icons
      and that behaviour.

      1. JXTableWithRowSorter.patch
        41 kB
        jessewilson
      2. RowSorter.java
        4 kB
        jessewilson
      3. RowSorter.java
        2 kB
        jessewilson

        Activity

        Hide
        jessewilson added a comment -

        Created an attachment (id=49)
        proposed interface to bind a JXTable's header to the model sorter

        Show
        jessewilson added a comment - Created an attachment (id=49) proposed interface to bind a JXTable's header to the model sorter
        Hide
        jessewilson added a comment -

        Created an attachment (id=50)
        Support RowSorter within JXTable, to allow pluggable sorting implementations

        Show
        jessewilson added a comment - Created an attachment (id=50) Support RowSorter within JXTable, to allow pluggable sorting implementations
        Hide
        jessewilson added a comment -

        Created an attachment (id=51)
        Revision of RowSorter interface to support externalized sorting in JXTable

        Show
        jessewilson added a comment - Created an attachment (id=51) Revision of RowSorter interface to support externalized sorting in JXTable
        Hide
        jessewilson added a comment -

        I've attached a patch file and 2 revisions of RowSorter.java, that fully implements my desired functionality.
        I've also independently implemented this interface for the Glazed Lists sorter to verify that external
        sorting works. Note that only the more recent of the two RowSorter.java files is valid!

        I've smoke tested this code, rearranging columns, modifying the model, removing columns, and
        everything seems to work fine.

        I would very highly like this code to be integrated into the HEAD branch of JXTable so that Glazed Lists
        users can start to take advantage of JXTable's great features. Hopefully someone official can find time to
        peer review this code and commit it if it's deemed worthy!

        Show
        jessewilson added a comment - I've attached a patch file and 2 revisions of RowSorter.java, that fully implements my desired functionality. I've also independently implemented this interface for the Glazed Lists sorter to verify that external sorting works. Note that only the more recent of the two RowSorter.java files is valid! I've smoke tested this code, rearranging columns, modifying the model, removing columns, and everything seems to work fine. I would very highly like this code to be integrated into the HEAD branch of JXTable so that Glazed Lists users can start to take advantage of JXTable's great features. Hopefully someone official can find time to peer review this code and commit it if it's deemed worthy!
        Hide
        kleopatra added a comment -

        further discussion:
        http://forums.java.net/jive/thread.jspa?threadID=13451

        first steps:

        • added SortOrder,
        • let Sorter use SortOrder
        • added/changed public sorter api on JXTable (as mentioned in the thread)
        • updated ColumnHeaderRenderer, JXTableHeader (maybe others, used the rename
          refactoring, sorry....), related tests to use new api
        • added sanity tests for SortOrder and using classes
        Show
        kleopatra added a comment - further discussion: http://forums.java.net/jive/thread.jspa?threadID=13451 first steps: added SortOrder, let Sorter use SortOrder added/changed public sorter api on JXTable (as mentioned in the thread) updated ColumnHeaderRenderer, JXTableHeader (maybe others, used the rename refactoring, sorry....), related tests to use new api added sanity tests for SortOrder and using classes
        Hide
        kleopatra added a comment -

        related - request for public sorter api on JXTable
        https://swingx.dev.java.net/issues/show_bug.cgi?id=11

        Show
        kleopatra added a comment - related - request for public sorter api on JXTable https://swingx.dev.java.net/issues/show_bug.cgi?id=11
        Hide
        kleopatra added a comment -

        cont'd:

        • removed all references to Sorter, except inside the decorator package
        • the interactive sort control is factored into the SortController
        • FilterPipeline exposes the SortController for client usage
        • updated the doc

        To externalize (or otherwise configure the interactive sort control) subclass
        FilterPipeline and let it return a custom SortController.

        I'll close this as the requested requirement now is met. Future work will go
        into Issue #286.

        Jeanette

        Show
        kleopatra added a comment - cont'd: removed all references to Sorter, except inside the decorator package the interactive sort control is factored into the SortController FilterPipeline exposes the SortController for client usage updated the doc To externalize (or otherwise configure the interactive sort control) subclass FilterPipeline and let it return a custom SortController. I'll close this as the requested requirement now is met. Future work will go into Issue #286. Jeanette

          People

          • Assignee:
            kleopatra
            Reporter:
            jessewilson
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: