swingx
  1. swingx
  2. SWINGX-272

Create alternative to DefaultListSelectionModel with better behaviour

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.9.0
    • Fix Version/s: None
    • Component/s: Table
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Macintosh

    • Issuezilla Id:
      272

      Description

      JXTable's default selection mode is MULTIPLE_INTERVAL_SELECTION. When a row is inserted into a JXTable
      with the this selection model, that row becomes selected if it is inserted immediately before a selected
      row. This is annoying, particularly when using dynamic filtering with JXTable, because elements appear
      and disappear frequently, which should not impact selection.

      Instead, inserted rows should be deselected by default, regardless of the selection of the elements they
      are inserted beside.

        Activity

        Hide
        kleopatra added a comment -

        hmm, that's standard JTable behaviour, or more precisely: documented behaviour
        of DefaultListSelectionModel.insertIndexInterval:

        /**

        • Insert length indices beginning before/after index. If the value
        • at index is itself selected and the selection mode is not
        • SINGLE_SELECTION, set all of the newly inserted items as selected.
        • Otherwise leave them unselected. This method is typically
        • called to sync the selection model with a corresponding change
        • in the data model.
          */

        The only way out might be a custom ListSelectionModel implementation.

        I added test methods (both visual and unit testing) to JTableIssues. Let me know
        if that's what you mean.

        Jeanette

        Show
        kleopatra added a comment - hmm, that's standard JTable behaviour, or more precisely: documented behaviour of DefaultListSelectionModel.insertIndexInterval: /** Insert length indices beginning before/after index. If the value at index is itself selected and the selection mode is not SINGLE_SELECTION, set all of the newly inserted items as selected. Otherwise leave them unselected. This method is typically called to sync the selection model with a corresponding change in the data model. */ The only way out might be a custom ListSelectionModel implementation. I added test methods (both visual and unit testing) to JTableIssues. Let me know if that's what you mean. Jeanette
        Hide
        jessewilson added a comment -

        Yeah, I think the default JTable behaviour works, but it's not well suited for dynamic filtering. Perhaps this
        isn't as big a deal 'cause JXTable doesn't really do 'interactive' filtering out-of-the-box. With Glazed Lists I
        found that when doing interactive filtering (like iTunes), the default selection model behaviour was really
        lame and we wrote a custom ListSelectionModel with better behaviour. I opened this issue to suggest
        JXTable get that better behaviour as well.

        Show
        jessewilson added a comment - Yeah, I think the default JTable behaviour works, but it's not well suited for dynamic filtering. Perhaps this isn't as big a deal 'cause JXTable doesn't really do 'interactive' filtering out-of-the-box. With Glazed Lists I found that when doing interactive filtering (like iTunes), the default selection model behaviour was really lame and we wrote a custom ListSelectionModel with better behaviour. I opened this issue to suggest JXTable get that better behaviour as well.
        Hide
        kleopatra added a comment -

        hmm ... don't know exactly what you mean be "interactive" filtering, but it's
        easily implementable in Swingx (the jdnc layer used to have an example). I never
        saw a problem with the selectionModel, probably because filtering doesn't imply
        any artificial insert/remove events. The selection is kept in terms of model
        coordinates and view selection updated accordingly.

        So, I don't see any inherent need of another ListSelectionModel - but if you
        would like to contribute your implementation than developers are free to choose
        the behaviour they want.

        Jeanette

        Show
        kleopatra added a comment - hmm ... don't know exactly what you mean be "interactive" filtering, but it's easily implementable in Swingx (the jdnc layer used to have an example). I never saw a problem with the selectionModel, probably because filtering doesn't imply any artificial insert/remove events. The selection is kept in terms of model coordinates and view selection updated accordingly. So, I don't see any inherent need of another ListSelectionModel - but if you would like to contribute your implementation than developers are free to choose the behaviour they want. Jeanette
        Hide
        jessewilson added a comment -

        Jeanette, you're right. I was testing JXTable using Glazed Lists' filtering in
        the model, which caused the selection to behave wildly. But if selection is
        maintained post-filter, then this problem mostly disappears.

        I still think that for dynamic datasets the default behaviour of
        DefaultListSelectionModel is bad, but that's unrelated to filtering.

        Perhaps a better use case would be when data is streamed to a JXTable that has
        selection. In this case, a newly loaded row inserted immediately before a
        selected row becomes selected, which is weird behaviour.

        Show
        jessewilson added a comment - Jeanette, you're right. I was testing JXTable using Glazed Lists' filtering in the model, which caused the selection to behave wildly. But if selection is maintained post-filter, then this problem mostly disappears. I still think that for dynamic datasets the default behaviour of DefaultListSelectionModel is bad, but that's unrelated to filtering. Perhaps a better use case would be when data is streamed to a JXTable that has selection. In this case, a newly loaded row inserted immediately before a selected row becomes selected, which is weird behaviour.
        Hide
        kleopatra added a comment -

        okay, so we agree that the issue boils down to DefaultListSelectionModel
        behaviour, which might be sub-optimal on insertIndexInterval? (personally, I
        never liked it as well)

        If so, we should change the summary accordingly and make it an RFE issue on the
        selection model (are you aware of some related issue in core bug parade?)

        Thanks
        Jeanette

        Show
        kleopatra added a comment - okay, so we agree that the issue boils down to DefaultListSelectionModel behaviour, which might be sub-optimal on insertIndexInterval? (personally, I never liked it as well) If so, we should change the summary accordingly and make it an RFE issue on the selection model (are you aware of some related issue in core bug parade?) Thanks Jeanette
        Hide
        jessewilson added a comment -

        I've revised the summary of this issue, here's the revised description:
        DefaultListSelectionModel inserts rows as they're selected. This behaviour is
        awkward. SwingX should provide an alternative to DefaultListSelectionModel with
        better behaviour, ie. inserted rows are not selected.

        This could be implemented by creating a custom ListSelectionModel that supports
        a new mode value, with a name like "MULTIPLE_INTERVAL_SELECTION_DEFENSIVE" where
        the defensive implies a defensive attitude to selecting new rows.

        Show
        jessewilson added a comment - I've revised the summary of this issue, here's the revised description: DefaultListSelectionModel inserts rows as they're selected. This behaviour is awkward. SwingX should provide an alternative to DefaultListSelectionModel with better behaviour, ie. inserted rows are not selected. This could be implemented by creating a custom ListSelectionModel that supports a new mode value, with a name like "MULTIPLE_INTERVAL_SELECTION_DEFENSIVE" where the defensive implies a defensive attitude to selecting new rows.
        Hide
        kleopatra added a comment -

        Target: POST-1.0

        Show
        kleopatra added a comment - Target: POST-1.0
        Hide
        kleopatra added a comment -


        postponed

        Show
        kleopatra added a comment - postponed

          People

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

            Dates

            • Created:
              Updated: