IllegalStateException when sorting via table headers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

IllegalStateException when sorting via table headers

JohnPM
I am getting java.lang.IllegalStateException: Cannot combine reorder with other change events when sorting a list via the table headers. I found an old post with this problem, which implied it was resolved by avoiding accessing the list selection model, but I'm not clear how I can use the list if I don't use the selection model! The exception appears to be trigggered by processing of a ListSelectionEvent, i.e.

    public void valueChanged(ListSelectionEvent lse){
        if (lse.getSource() == myListSelectionModel){
            if (!lse.getValueIsAdjusting()){
                /** React to changes in the selected entries */
                selectedEntries = myListSelectionModel.getSelected();
            }
        }
    }

If I comment out the access to getSelected() the exception no longer occurs, but of course I then do not get the selected entries. Any idea how I resolve this? I have tried the latest dev build and it has the same behaviour.

Edit: Here are the exception details:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Cannot combine reorder with other change events
        at ca.odell.glazedlists.event.ListEventAssembler.reorder(ListEventAssembler.java:246)
        at ca.odell.glazedlists.ListSelection.addSelectedReorder(ListSelection.java:852)
        at ca.odell.glazedlists.ListSelection.listChanged(ListSelection.java:172)
        at ca.odell.glazedlists.event.ListEventAssembler$ListEventFormat.fire(ListEventAssembler.java:412)
        at ca.odell.glazedlists.event.ListEventAssembler$ListEventFormat.fire(ListEventAssembler.java:409)
        at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher$SubjectAndListener.firePendingEvent(SequenceDependenciesEventPublisher.java:445)
        at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:344)
        at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:316)
        at ca.odell.glazedlists.SortedList.setComparator(SortedList.java:478)
        at ca.odell.glazedlists.gui.AbstractTableComparatorChooser.rebuildComparator(AbstractTableComparatorChooser.java:154)
        at ca.odell.glazedlists.swing.TableComparatorChooser.rebuildComparator(TableComparatorChooser.java:295)
        at ca.odell.glazedlists.gui.AbstractTableComparatorChooser$SortingStateListener.propertyChange(AbstractTableComparatorChooser.java:140)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
        at ca.odell.glazedlists.impl.gui.SortingState.fireSortingChanged(SortingState.java:67)
        at ca.odell.glazedlists.impl.gui.MouseOnlySortingStrategy.columnClicked(MouseOnlySortingStrategy.java:65)
        at ca.odell.glazedlists.swing.TableComparatorChooser$HeaderClickHandler.mouseClicked(TableComparatorChooser.java:568)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6266)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6028)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2475)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        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)
Reply | Threaded
Open this post in threaded view
|

Re: IllegalStateException when sorting via table headers

JohnPM
JohnPM wrote
I am getting java.lang.IllegalStateException: Cannot combine reorder with other change events when sorting a list via the table headers. I found an old post with this problem, which implied it was resolved by avoiding accessing the list selection model, but I'm not clear how I can use the list if I don't use the selection model! The exception appears to be trigggered by processing of a ListSelectionEvent, i.e.

    public void valueChanged(ListSelectionEvent lse){
        if (lse.getSource() == myListSelectionModel){
            if (!lse.getValueIsAdjusting()){
                /** React to changes in the selected entries */
                selectedEntries = myListSelectionModel.getSelected();
            }
        }
    }

If I comment out the access to getSelected() the exception no longer occurs, but of course I then do not get the selected entries. Any idea how I resolve this? I have tried the latest dev build and it has the same behaviour.
Problem solved - another event processing path was (wrongly) triggering a clearSelection().