Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 1 (11.1.1)

E10653-03


oracle.jbo.uicli.jui
Class JUTableSortModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by oracle.jbo.uicli.jui.JUTableSortModel

All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel

public class JUTableSortModel
extends javax.swing.table.AbstractTableModel
implements javax.swing.event.TableModelListener

Implements a sorting filter over JUTableBinding's TableModel such that when a user clicks (or Shift_click) on a column header of the Table, the display of rows from the JUTableBinding (and hence BC4J), is sorted by that column.

This class is a customization of TableSorter in Sun's JFC example that can also be found at (JDEVELOPER_HOME)/jdk/demo/jfc/TableExample. For details on how the basic TableSorter works, please see this JFC example.

This class implements the following enhancements over the base Sun's TableSorter:

See Also:
Serialized Form

Field Summary

 

Fields inherited from class javax.swing.table.AbstractTableModel
listenerList

 

Constructor Summary
JUTableSortModel()
          Default Constructor just coz, base class has it.
JUTableSortModel(JUTableBinding model)
          Constructor that sets up this sorting model on top of the existing Table model.

 

Method Summary
 void addMouseListenerToHeaderInTable(javax.swing.JTable table)
          Override to add an action by which to reset the sorting order to the fetch order If one clicks on the same column again (or the Shift+click if the current sorting order is descending), then the Table resorts to the default row order as returned by BC4J.
protected  void checkModel()
          If no sorting is to be done or when the base model has different row count, resets the indices map so that sorting is done again.
protected  int compareObjectTypes(java.lang.Object obj1, java.lang.Object obj2)
          Converts unknown Object types to String and compares the Strings.
protected  int compareRows(int row1, int row2)
          Compares the sort-column values in two rows.
protected  int compareRowsByColumn(int row1, int row2, int column)
          Compares the values in two rows at the given column.
static javax.swing.table.TableModel enableColumnSorting(javax.swing.JTable table, JUTableBinding tableBinding, JUTableSortModel sorter)
          JClient method to attach column-sorting model over a Table that's bound to a JUTableBinding.
 java.lang.Class getColumnClass(int aColumn)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int aColumn)
           
 int getRowCount()
           
 JUTableBinding getTableBinding()
          Returns the TableModel that this class is sorting.
 java.lang.Object getValueAt(int aRow, int aColumn)
           
protected  void initType()
          Initializes the java type that this class is sorting on.
 boolean isCellEditable(int aRow, int aColumn)
           
protected  void reallocateIndexes()
          If sort-column is greater than -1 (when no sorting should be done), sorts the data from the base model for display.
protected  void resetIndices()
          Initializes the mapping between indices of this model versus the base model.
protected  void setTableBinding(JUTableBinding mdl)
          Sets the TableModel on top of which this sorter works.
 void setValueAt(java.lang.Object aValue, int aRow, int aColumn)
           
protected  void shuttlesort(int[] from, int[] to, int low, int high)
           
 void sortByColumn(int column, boolean ascending)
          Stores the mSortColIndex if it has changed.
protected  void swap(int i, int j)
          Swaps the index map between two given indices.
 void tableChanged(javax.swing.event.TableModelEvent e)
           

 

Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

JUTableSortModel

public JUTableSortModel()
Default Constructor just coz, base class has it.

JUTableSortModel

public JUTableSortModel(JUTableBinding model)
Constructor that sets up this sorting model on top of the existing Table model.

Method Detail

setTableBinding

protected void setTableBinding(JUTableBinding mdl)
Sets the TableModel on top of which this sorter works.

checkModel

protected void checkModel()
If no sorting is to be done or when the base model has different row count, resets the indices map so that sorting is done again.

compareRows

protected int compareRows(int row1,
                          int row2)
Compares the sort-column values in two rows.
Returns:
  • a positive number when column value in row1 is greater than row1,
  • 0 when the two values match
  • a negative number when column value in row1 is less than row2.

resetIndices

protected void resetIndices()
Initializes the mapping between indices of this model versus the base model.

reallocateIndexes

protected void reallocateIndexes()
If sort-column is greater than -1 (when no sorting should be done), sorts the data from the base model for display. Otherwise, simply resets this class' index map.

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Specified by:
tableChanged in interface javax.swing.event.TableModelListener

initType

protected void initType()
Initializes the java type that this class is sorting on. This implementation special cases the following types: