glazedlists
  1. glazedlists
  2. GLAZEDLISTS-474

Table view indexes mismatched with model indexes

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: swing
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All
      URL: http://kari.world.dy.fi

    • Issuezilla Id:
      474

      Description

      I've table model, which uses model indexes for columns starting from 10. It
      seems that at least sorting logic in glazed lists table model fails with this
      (AIOOBE: Index: 10, Size: 2, where 10 is modelIndex, and 2 is actual column
      count in table). i.e. logic assumes model indexes to use view indexing logic.
      With Swing table it's very crucial to not confuse these two concepts with each.

      For various reasons it's very usefull to use other indexing than 0 based
      indexing for columns in model. In other words this is showstopper, since glazed
      lists doesn't work.

      Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException:
      Index: 10, Size: 2
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.get(ArrayList.java:322)
      at
      ca.odell.glazedlists.gui.AbstractTableComparatorChooser.getSortingStyle
      (AbstractTableComparatorChooser.java:264)
      at ca.odell.glazedlists.swing.TableComparatorChooser.getSortingStyle
      (TableComparatorChooser.java:309)
      at ca.odell.glazedlists.swing.TableComparatorChooser
      $SortArrowHeaderRenderer.getTableCellRendererComponent
      (TableComparatorChooser.java:490)
      at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer
      (BasicTableHeaderUI.java:663)
      at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight
      (BasicTableHeaderUI.java:698)
      at javax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize
      (BasicTableHeaderUI.java:727)
      at javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize
      (BasicTableHeaderUI.java:758)
      at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
      at javax.swing.ViewportLayout.preferredLayoutSize
      (ViewportLayout.java:78)
      at java.awt.Container.preferredSize(Container.java:1599)
      at java.awt.Container.getPreferredSize(Container.java:1584)
      at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
      at javax.swing.ScrollPaneLayout.layoutContainer
      (ScrollPaneLayout.java:702)
      at java.awt.Container.layout(Container.java:1421)
      at java.awt.Container.doLayout(Container.java:1410)
      at java.awt.Container.validateTree(Container.java:1507)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validateTree(Container.java:1513)
      at java.awt.Container.validate(Container.java:1480)
      at java.awt.Window.show(Window.java:860)
      at java.awt.Component.show(Component.java:1516)
      at java.awt.Component.setVisible(Component.java:1468)
      at java.awt.Window.setVisible(Window.java:841)
      at org.kari.perspective.KApplicationFrame.setVisible
      (KApplicationFrame.java:48)
      at org.kari.foo.Bar.run(Bar.java:35)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters
      (EventDispatchThread.java:269)
      at java.awt.EventDispatchThread.pumpEventsForFilter
      (EventDispatchThread.java:184)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy
      (EventDispatchThread.java:174)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

        Activity

        Hide
        kikonen added a comment -

        Figured out workaround:

        • Had to override completely (i.e. copy/paste code)
        • SortingState
          ~ has Map<modelIndex, SortingColumn>
        • TableComparatorChooser
        • MouseSortingStrategy
        • Add new interface to get model indexes from table format
        • SortableTableFormat { int[] getModelIndexes(); }

        Important point is that model indexes can be arbitary integer values (ex. 10,
        12, 100, 7500) so Map is required.

        Show
        kikonen added a comment - Figured out workaround: Had to override completely (i.e. copy/paste code) SortingState ~ has Map<modelIndex, SortingColumn> TableComparatorChooser MouseSortingStrategy Add new interface to get model indexes from table format SortableTableFormat { int[] getModelIndexes(); } Important point is that model indexes can be arbitary integer values (ex. 10, 12, 100, 7500) so Map is required.
        Hide
        kikonen added a comment -

        I've done fix for this, and also implemented some other related improvements in
        TreeList (column sorting suppport).

        Currently they are in my fork of the glazedlists codebase, but naturally I would
        like to get them included in the actual version.

        Any interest?

        Show
        kikonen added a comment - I've done fix for this, and also implemented some other related improvements in TreeList (column sorting suppport). Currently they are in my fork of the glazedlists codebase, but naturally I would like to get them included in the actual version. Any interest?

          People

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

            Dates

            • Created:
              Updated: