SortableTable issues

A discussion forum for the JCommon class library.

SortableTable issues

Postby jdetwiler » Thu Jan 03, 2008 9:09 pm

I have a couple questions/issues relating to the use of SortableTables. First, after clicking on a column, the sort runs and the data is redrawn. How exactly is this happening? I would expect some event to be fired, but I don't see it. The table data has changed but no TableModelEvent fired? Is it simply repainting the whole table? Related to this, there is currently no listener for the sorted column index and ascending flag. There are times I'd like to be notified of this change.

Second, the selection seems to not be updated when sorting occurs. That is, if index 0 is selected, then the table sorted, index 0 is still selected even if the value at index 0 is now somewhere else. This is most likely related to the first point since no event is triggered. Is this the desired behavior? If so, while it's true the selection didn't change (still index 0) the item selected may in fact have changed but there's no notification of this.

Any opinions, suggestions, previous experience in this area appreciated.
jdetwiler
 
Posts: 2
Joined: Thu Jan 03, 2008 9:00 pm

Re: SortableTable issues

Postby david.gilbert » Thu Jan 03, 2008 11:37 pm

jdetwiler wrote:I have a couple questions/issues relating to the use of SortableTables. First, after clicking on a column, the sort runs and the data is redrawn. How exactly is this happening? I would expect some event to be fired, but I don't see it. The table data has changed but no TableModelEvent fired? Is it simply repainting the whole table? Related to this, there is currently no listener for the sorted column index and ascending flag. There are times I'd like to be notified of this change.


It's a long time since I looked at this code. It looks as though the table repaint is triggered by the SortableTableHeaderListener.mouseReleased() method. I think it would probably be smarter if the repaint was triggered by a TableModelEvent, as you're suggesting.

jdetwiler wrote:Second, the selection seems to not be updated when sorting occurs. That is, if index 0 is selected, then the table sorted, index 0 is still selected even if the value at index 0 is now somewhere else. This is most likely related to the first point since no event is triggered. Is this the desired behavior? If so, while it's true the selection didn't change (still index 0) the item selected may in fact have changed but there's no notification of this.


Yeah, that's wrong. Given the age of the code, my first advice would be to look around for a better alternative (maybe in SwingLabs?). If you don't find anything, then let's fix this code (JCommon isn't the highest priority for me right now, its being phased out as a JFreeChart dependency - but if there's no alternative around, fixing the JCommon code would make sense).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11617
Joined: Fri Mar 14, 2003 10:29 am

Postby jdetwiler » Fri Jan 04, 2008 2:12 am

So is JCommon as a whole not being supported? Or just some parts?

If not, I haven't yet been involved in an open source project, but as I've been a proponent of using JFreeChart in my last few jobs, I see some value in pitching in. In particular, code such as a SortableTable is right up my alley.
jdetwiler
 
Posts: 2
Joined: Thu Jan 03, 2008 9:00 pm

Postby david.gilbert » Fri Jan 04, 2008 4:54 pm

Regarding JCommon, both Thomas (for Pentaho Reporting, formerly JFreeReport) and I (for JFreeChart) agree that JCommon has become a little redundant as a shared library, since we're not actually sharing that much code between our projects. Certainly not enough to justify the extra entry on the classpath, handling version dependencies etc. For JFreeChart, I plan to copy across the subset of JCommon classes I use into the org.jfree.chart.util.* package space, and do away with the JCommon dependency. I think Thomas has something similar planned.

SortableTable will get left behind in that, because neither project uses it directly. However, I will be doing some work with tables this year, so maybe we can collaborate on it (and I know more about Swing than I did when I originally pieced together the SortableTable class). If SwingLabs doesn't already have something, it would probably make sense to try to get it supported there. If/until that happens, I'd be happy to host a small "SortableTable" project here at JFree.org.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11617
Joined: Fri Mar 14, 2003 10:29 am


Return to JCommon

Who is online

Users browsing this forum: No registered users and 2 guests