navtable/navtable — pull request #84 by fpuga (2014-10-09 10:37:57+00:00)
Title: Navigate features sorted

This pull request introduces a new feature in navtable to be able to navigate the features in a sort order defined by the user.

9fb7474 extracts all the logic about navigation (first, last,...) to a new "Navigation" class. I change the visibility of some methods in AbstractNavtable.

My idea in next steps is try to build a new class (¿Selection?) that handles all the selection stuff and the interaction between AbstractNavtable, Selection and Navigation happens through events. But i'm not pretty sure about this jet.

**Do you think Navigation/Selection are good class names?**
** How do you think that should be the interaction between this classes?** Check c3dbb1d and a2c52f3 I opted for use AbstractNavtable as a master controller. Navigation can also create its own listener on the layer or the model but i found this a bit more confusing.

4d89f02 is the new sorter class. I look up for examples and the most similar case is the RowSorter of JTables so i based my solution in this class. It's a bit complex but, i think that this feature is also complex a use RowSorter allow us to grow in the future.

As the "data model" (DefaultTableModel in TableRowSorter) i've used SelectableDataSource. I'm not sure about this decision. At first i try to use IController, but for the sorter i need to access all the features - getRowCount(), getValueAt(row, column), ... - and not only one record so i choose this approach.

9ca903a Instead of allow external classes set the sorter, they are only allowed to set the sort keys. Is Navigation which based on its internal state decides which is the sorter class that should be used.

71e9189 navigate only through selected records when they are sorted is a bit difficult. I think in two options there, have a bitset with the bits sorted, or calculate by hand the next/previous selected bit. I choose the second approach, but must be tested with many records that it performs well.

I check that the sorter works correctly when an edition event occur (update/delete a record from nt or external, and even when the table structure changed)

Rigth click on a field of the table displays a menu with 4 new options (sort asc, sort desc, sort advanced, default sort). Click in one of then triggers the sort. *I'm still thinking about the interface for the sort advanced, that must allow select a couple of fields for the sort, but i'm not sure how this interface should look like*.