Re: EventListJXTableSorting

View: New views
1 Messages — Rating Filter:   Alert me  

Re: EventListJXTableSorting

by Holger Brands :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Boomah,

The latest build available here
https://glazedlists.dev.java.net/servlets/ProjectDocumentList?folderID=3916&expandFolder=3916&folderID=3916
contains a new install method
EventListJXTableSorting#install(JXTable, SortedList, Comparator)
where you can specify a default comparator
which will be used when there are no sort keys.

In your example you would use
EventListJXTableSorting.install(imageTable, sortedList, sortedList.getComparator());
to get the desired effect.

Hope this helps,
Holger

> Boomah, James,
>
> I could offer some help here, if you like.
> Here are some more infos:
>
> Here is a thread dump for SortedList.setComparator(..)
> produced with your sample app:
>
> SortedList.setComparator(): null
> java.lang.Exception: Stack trace
> at java.lang.Thread.dumpStack(Thread.java:1158)
> at ca.odell.glazedlists.SortedList.setComparator(SortedList.java:435)
> at ca.odell.glazedlists.swing.EventListJXTableSorting$EventListSortController.setSortKeys(EventListJXTableSorting.java:214)
> at org.jdesktop.swingx.JXTable.setFilters(JXTable.java:1733)
> at ca.odell.glazedlists.swing.EventListJXTableSorting.<init>(EventListJXTableSorting.java:92)
> at ca.odell.glazedlists.swing.EventListJXTableSorting.install(EventListJXTableSorting.java:100)
> at JXTableSorting.<init>(JXTableSorting.java:48)
> at JXTableSorting$3.run(JXTableSorting.java:117)
> ...
>
>
> EventListJXTableSorting.install(...) installs a new FilterPipeline on JXTable
> to provide its own SortController (JXTable.setFilters(...)).
> JXTable calls back into the new SorController to set the sort keys of the old SortController,
> which appear to be null or empty in this case.
> The EventListSortController tries to build a comparator from the sort keys,
> see EventListSortController.setSortKeys(...)
> If there are no sort keys, it sets the comparator of the SortedList to null.
> This is what happens in the example app.
>
> One thing we could do is to memorize the comparator of the SortedList at the time
> EventListJXTableSorting.install(...) is called and restore this comparator instead if null
> when EventListSortController.setSortKeys(...) is called with no sort keys.
>
> Hope this helps,
> Holger
>
> >Boomah,
> >
> >  I'll try to get a bit of time to dig into your test app (thanks very
> > much for producing that). I don't have a lot of experience with
> > JXTable, but we'll get to the bottom of it...
> >
> > James
> >
> > On Mon, May 11, 2009 at 9:25 AM, Boomah <nickdarcy@...> wrote:
> >
> > Just a bit more info. It appears the call to
> > EventListJXTableSorting.install(table, sortedList); is setting my
> > comparator
> > to null, which I suppose is what we expect if the list becomes
> > unsorted.
> >
> > Thanks, Nick.
> >
> > Steve Newell wrote:
> > >
> > > I am attempting to create a table using JXTable and glazedLists. My
> > > problem is the sorting. Things seem to work fine UNLESS I call
> > >
> > > EventListJXTableSorting.install( imageTable, sortedList );
> > >
> > > When I add that call, the table is not sorted until I select one of
> > > the headers.
> > >
> > > Here is the method that creates the table:
> > >
> > > private JScrollPane getFilteredList()
> > > {
> > > JScrollPane scrollImageTable = null;
> > >
> > > imageList.getReadWriteLock().writeLock().lock();
> > > try
> > > {
> > > SortedList< ImageSignature > sortedList = new SortedList<
> > > ImageSignature >( imageList, new ImageSizeComparator() );
> > > EventTableModel< ImageSignature > tableModel = new EventTableModel<
> > > ImageSignature >( sortedList, new ImageTableFormat() );
> > > JXTable imageTable = new DroppableTable( tableModel );
> > >
> > > EventListJXTableSorting sorting = EventListJXTableSorting.install
> > > ( imageTable, sortedList );
> > > sorting.setMultipleColumnSort( false );
> > >
> > > scrollImageTable = new JScrollPane( imageTable );
> > >
> > > imageTable.setHighlighters
> > > ( HighlighterFactory.createAlternateStriping(), new
> > > RolloverHighlighter( Color.BLACK, Color.white ) );
> > > imageTable.setRolloverEnabled( true );
> > > imageTable.setHorizontalScrollEnabled( true );
> > >
> > > imageTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
> > > imageTable.setColumnControlVisible( true );
> > >
> > > TableSelectionListener selectionListener = new
> > > TableSelectionListener( imageTable );
> > > imageTable.getSelectionModel().addListSelectionListener
> > > ( selectionListener );
> > > }
> > > finally
> > > {
> > > imageList.getReadWriteLock().writeLock().unlock();
> > > }
> > >
> > > return scrollImageTable;
> > > }
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/EventListJXTableSor
> > ting-tp11801610p23486682.html
> >
> > Sent from the GlazedLists - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
>
>
> __________________________________________________________________________
> Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele
> ausländische Netze zum gleichen Preis!
> https://produkte.web.de/webde_sms/sms
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...