Ontimize 5.2072EN

com.ontimize.gui.table
Class TableSorter

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended bycom.ontimize.gui.table.TableMap
          extended bycom.ontimize.gui.table.TableSorter
All Implemented Interfaces:
java.util.EventListener, Freeable, Internationalization, java.io.Serializable, javax.swing.table.TableModel, javax.swing.event.TableModelListener

public class TableSorter
extends TableMap
implements Freeable, Internationalization

A sorter for TableModels. The sorter has a model (conforming to TableModel) and itself implements TableModel. TableSorter does not store or copy the data in the TableModel, instead it maintains an array of integers which it keeps the same size as the number of rows in its model. When the model changes it notifies the sorter that something has changed e.g. "rowsAdded" so that its internal array of integers can be reallocated. As requests are made of the sorter (like getValueAt(row, col) it redirects them to its model via the mapping array. That way the TableSorter appears to hold another copy of the table with the rows in a different order. The sorting algorithm used is stable which means that it does not move around rows when its comparison function returns 0 to denote that they are equivalent. The sorter presents as well filtering and grouping features. That means that the TableSorter has a GroupTableModel inside that provides the grouping functionality and the GroupTableModel itself has a FilterTableModel inside. The table row indexes corresponds to the indexes in the TableSorter. Because if the sorting and grouping behaviors, the row indexes in the view might not be equal to the indexes in the table model, that is, the more internal model of those.

See Also:
Serialized Form

Nested Class Summary
static class TableSorter.ColumnSizeEvent
          Class that contains the event information corresponding to the change of the size of a column.
static interface TableSorter.ColumnSizeListener
          Interface used to notify the TableSorter that a column size change event.
static class TableSorter.DateFilter
          Class that represents a filter to a table column.
protected static class TableSorter.DayMonthYear
          Class that contains date information with day, month and year, to allow fast comparisons when sorting.
static class TableSorter.DefaultFilterValidator
          The default implementation of the FilterValidator interface.
static class TableSorter.DifferentFilter
          Class that represents a filter to a table column.
static class TableSorter.DifferentSimpleFilter
          Class that represents a simple filter for a table column.
static class TableSorter.Filter
          Class that represents a filter to a table column.
 class TableSorter.FilterTableModel
           
static interface TableSorter.FilterValidator
          Interface that must be implemented by the objects that can be used as table filters
 class TableSorter.GroupTableModel
           
protected static class TableSorter.IconN
           
protected static class TableSorter.Month
          Class that contains date information, concretely dates, to allow fast comparisons when sorting.
protected static class TableSorter.MonthYear
          Class that contains date information with month and year, to allow fast comparisons when sorting.
static class TableSorter.MultipleFilter
          Class that represents a filter to a table column.
protected static class TableSorter.Quarter
          Class that contains date information, concretely quarters, to allow fast comparisons when sorting.
protected static class TableSorter.QuarterYear
          Class that contains date information, concretely quarters and years, to allow fast comparisons when sorting.
static class TableSorter.SimpleFilter
          Class that represents a simple filter for a table column.
protected static class TableSorter.ValueByGroup
          Class that stores the cell values when these are obtained by groping several rows into one.
protected static class TableSorter.ValueByGroupDate
          Class that stores the cell values when these are obtained by groping several rows into one.
protected static class TableSorter.Year
          Class that contains date information, concretely months, to allow fast comparisons when sorting.
 
Field Summary
protected  boolean allowTotalInserting
           
protected  java.util.Vector ascendants
           
protected  java.lang.Object auxHeadValue
           
static int AVG
          Grouping operation type
 java.util.ResourceBundle bundle
           
static java.text.Collator comparator
           
protected  int compares
           
static int COUNT
          Grouping operation type
static boolean DEBUG
           
protected  FilterDialog filterDialog
           
protected  boolean filterEnabled
           
static java.lang.String filterKey
          Filtering preference key
protected  boolean fitHeadSize
           
static java.lang.String groupKey
          Deprecated.  
protected  int[] indexes
           
protected  java.util.Vector insertableCols
           
protected  boolean insertingEnabled
           
protected  java.util.Hashtable insertingRowData
           
protected  boolean lastIsSum
           
protected  boolean localSorter
           
static int MAX
          Grouping operation type
static int MIN
          Grouping operation type
static int MONTH
          A grouping type configuration parameter
static boolean MULTIORDER_PERMIT
          Allows or denies sorting the table by several columns
protected  java.util.Hashtable operationColumns
           
protected  boolean orderEnabled
           
static int QUARTER
          A grouping type configuration parameter
static int QUARTER_YEAR
          A grouping type configuration parameter
protected  int rowsNumber
           
protected  int rowsNumberToOrder
           
protected  TableSorter.ColumnSizeListener sizeColumnListener
           
protected  java.util.Vector sortingColumns
           
protected  javax.swing.JTable sourceTable
           
static int SUM
          Grouping operation type
protected  java.util.Vector sumColumns
           
static int YEAR
          A grouping type configuration parameter
static int YEAR_MONTH
          A grouping type configuration parameter
static int YEAR_MONTH_DAY
          A grouping type configuration parameter
 
Fields inherited from class com.ontimize.gui.table.TableMap
model
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface com.ontimize.gui.i18n.Internationalization
DEBUG_LANGUAGE
 
Constructor Summary
TableSorter(ExtendedTableModel model)
          Constructor.
TableSorter(ExtendedTableModel model, java.util.Vector sumColumns)
          Constructor.
TableSorter(ExtendedTableModel model, java.util.Vector sumColumns, java.util.Hashtable params)
           
 
Method Summary
 void addCalculatedColumn(java.lang.String columnName, java.lang.String expression)
           
 void addColumn(java.lang.String columnName)
          Adds a new column to the model.
 void addRow(java.util.Hashtable rowData)
          Adds a new row to the model.
 void addRow(int viewRowIndex, java.util.Hashtable rowData)
          Adds a new row in the position specified.
 void addRows(int[] viewRowIndex, java.util.Vector rowData)
          Deprecated.  
 void addRows(java.util.Vector rowData)
          The Vector contains Hashtables, each one stores the information of the column, this is, the keys are the column names and the values the values for each column.
 void applyFilter(java.util.Hashtable filters)
          Applies a group of filters to the table.
 void applyFilter(java.util.Hashtable filters, boolean or)
          Applies a group of filters to the table.
 void applyFilter(int columnIndex, java.lang.Object filter)
          Applies a filter to a column.
 boolean checkModel()
          Checks the model to ensure that all the changes in the model have been processed.
 void clearInsertingRow(java.util.Hashtable parentkeys)
           
 int compare(int rowIndex1, int rowIndex2)
          Compares two rows column by column, following the sorting of the columns.
 int compareRowsByColumn(int rowIndex1, int rowIndex2, int columnIndex)
          Compares to row values of the same column.
 int convertRowIndexToFilteredModel(int viewRowIndex)
          Converts the view index to the corresponding index in the filtered model.
 int convertRowIndexToModel(int viewRowIndex)
          Converts the view index into the corresponding model index.
 void deleteCalculatedColumn(java.lang.String columnName)
           
 void deleteColumn(java.lang.String columnName)
          Deletes a column from the model.
 void deleteRow(int rowIndex)
          Deletes the specified row.
 void deleteRows(int[] rowIndex)
          Deletes the specified rows from the model
 void enableFiltering(boolean enable)
          Enables or disables that filteringcan be applied to the table.
 void enableSort(boolean enable)
          Enables or disables sorting in the table
 void fireSizeColumnToFit(int columnIndex)
          Fires a TableSorter.ColumnSizeEvent to be processed by the TableSorter.ColumnSizeListener configured in the model.
 void fireTableChanged(javax.swing.event.TableModelEvent e)
          Method fired to update the table after a sorting.
 void free()
          Removes the table header listener and the model.
 boolean[] getAscendent()
          Returns the indexes of all the columns that has an ascending sorting in the table, following the sorting order.
 java.lang.String getCalculatedColumnExpression(java.lang.String columnName)
          Returns the column expression for the specified column name.
 java.util.Hashtable getCalculatedColumns()
          Returns the columns that have a calculated expression and the expression.
protected  java.util.Hashtable getCalculatedColumnsDependence(java.lang.String columnName)
          Get the columns that exist in the expression to calculate the specified column
 java.util.Vector getCalculatedColumnsName()
          Returns the names of the columns that have a calculated expression set.
 java.util.Hashtable getCalculatedRowData(int rowIndex)
          Returns a Hashtable with the information of the calculated columns for this row.
 java.lang.Object getCalculatedValue(int column, java.util.Hashtable rowValues)
           
 java.lang.Object getColumnFilter(java.lang.String columnName)
          Returns the filters applied to a column.
 java.lang.Object getColumnIdentifier(int modelColumnIndex)
          Returns the column name that corresponds to a specified index.
 java.util.Vector getColumnNames()
          Returns the column names.
protected  java.lang.Number getColumnOperation(int columnIndex)
           
protected  java.lang.Object getColumnOperation(java.lang.String columnIdentifier, java.lang.String operation)
           
 java.util.Vector getColumnsText()
          Returns the column texts.
protected  java.lang.Number getColumnSum(int modelColumnIndex, boolean average)
          Calculates the sum or the average for a column.
protected  java.lang.Number getColumnSum(int columnIndex, boolean average, int[] rowIndexes)
          Calculates the sum or the average value for a column; only the values of the specified rows will be used.
 java.lang.Number getColumnSum(java.lang.Object columnName)
          Sums all the values for a specified column.
protected  java.lang.Object getColumnType(java.lang.Object columnName)
          Returns the operation configured for a column.
 int getCurrentRowCount()
          Returns the index of the sumrow
 java.util.Hashtable getData()
          Returns all the information stored in the model, including the calculated columns.
 FilterDialog getFilterDialog()
           
 java.util.Vector getFilteredColumns()
          Returns the columns that are being filtered.
 java.util.Hashtable getFilteredData()
          Returns the data contained in the model but according to the filters that are being applied to that model
 java.util.Hashtable getFilters()
          Returns the filters for the table.
 TableSorter.FilterValidator getFilterValidator()
          Returns the filter validator configured in the model.
 int getFirstSortedColumn()
          Returns the index of the first sorted column.
 int getGroupedColumnFunction(int modelColumnIndex)
          Provides the function applied to the specified column
 java.util.Hashtable getGroupedRowData(int rowIndex)
          Returns the information contained in the specified row, in case that the table is grouped.
 java.util.Hashtable getInsertingData()
           
protected  java.lang.Number getMaximumMinimumColumn(int index, boolean max)
           
 java.util.Hashtable getOperationColumn()
          Returns the current operation columns.
 java.lang.Number getOperationColumn(java.lang.Object columnName)
          Returns the value of the operation applied to the specified column.
 int getRealRecordNumber()
          Returns the number of records or rows that are actually stored in the model.
 java.util.Vector getRequiredColumnsToCalculatedColumns()
           
 int getRowCount()
           
 java.util.Hashtable getRowData(int rowIndex)
          Returns the information contained in the specified row.
 java.util.Hashtable getRowDataForKeys(java.util.List keys, java.util.Hashtable keysValues)
           
protected  java.util.Hashtable getSelectedColumnOperation(int[] rowIndex)
          For each column that has an operation configured, returns the result of perform the operation in the rows passed as parameter.
protected  java.lang.Number getSelectedColumnOperation(java.lang.Object columnName, int[] rowIndex)
          Returns the result of the application of the configured operation (sum, maximum, etc.) to the rows passed as parameter for the specified column.
 java.util.Hashtable getShownValue()
          Returns the information contained in the model but the sumrows.
 java.util.Hashtable getShownValue(java.lang.String[] cols)
           
 int[] getSortingColumns()
          Returns the indexes of all the columns that has a sorting in the table, following the sorting order.
 javax.swing.table.TableCellRenderer getSumCellRenderer(boolean currency)
          Provides a renderer for the rum row.
 java.util.Vector getTextsToTranslate()
          Returns all the texts in the element suitable for being translated.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
 void group(int modelColumnIndex)
          Groups the model by a column.
 void group(int modelColumnIndex, int type)
          Groups the model by a column and using a concrete grouping approach.
 boolean isAscending()
          Determines whether the first sorting in the table is ascending or descending.
 boolean isAscending(int columnIndex)
          Determines whether a column sorting is ascending or not.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isFiltered()
          Determines whether the model is filtered or not.
 boolean isFiltered(int columnIndex)
          Determines whether the specified column us grouped or not.
 boolean isFilterEnabled()
           
 boolean isGrouped()
          Determines whether the table has a grouping applied or not.
 boolean isGrouped(int col)
          Determines whether a column is grouped or not.
 boolean isInsertingEnabled()
           
 boolean isInsertingRow(int row)
           
 boolean isLocalSorter()
          Checks if the sorter is local.
 boolean isSorted()
          Determines whether the table is being sorted or not.
 boolean isSorted(int columnIndex)
          Determines whether a column is sorted or not.
 boolean isSortEnabled()
          Checks if the sorting is enable.
 boolean isSum()
          Determines whether exists sum columns in the model.
 boolean isSumCell(int rowIndex, int colIndex)
          Determines whether a cell belongs to a sumrow or not.
 boolean isSumRow(int rowIndex)
          Determines whether a row is a sumrow, that is, is a row that displays the result of performing operations with the columns.
 boolean lastFilterOr()
           
 void n2sort()
          Deprecated.  
 void reallocateIndexes()
          Sets up a new array of indexes with the right number of elements for the new data model.
 void resetFilter()
          Removes all the filters from the table.
 void resetFilter(int columnIndex)
          Removes the filters from the column specified by its index.
 void resetFilter(java.lang.String columnName)
          Removes the filters from the column specified by its name.
 void resetGroup()
          Deletes all the grouping in the table.
 void resetOrder()
          Removes the sorting applied to the table.
 void resetOrder(int columnIndex)
          Removes the sorting applied to the column specified by its index.
 void setCalculatedColumnExpression(java.lang.String columnName, java.lang.String expression)
          Sets a calculated expression to a colum.
 void setComponentLocale(java.util.Locale l)
           
 void setData(java.util.Hashtable data)
          Sets a new group of data to the model.
 void setEditableColumn(java.lang.String columnName)
          Allows a column to be editable, that is, sets a editor to the column in order that the column value can be editable from the GUI.
 void setEditableColumn(java.lang.String columnName, boolean editable)
          Configures a column to be editable or not.
 void setFilterDialog(FilterDialog filterDialog)
           
 void setFilterValidator(TableSorter.FilterValidator filterValidator)
          Sets a TableSorter.FilterValidator to the model.
 void setFitHeadSize(boolean fit)
          Configures the table to auto adjust the header size.
 void setGroupedColumnFunction(int modelColumnIndex, int function)
          Applies a function to a column.
 void setInsertEnabled(boolean enabled)
          Enable or disable the inserting row
 void setLocalSorter(boolean localSorter)
           
 void setModel(TableSorter.GroupTableModel model)
          Sets a new GroupTableModel to this TableSorter.
 void setOperationColumns(java.util.Hashtable operationColumns)
          Sets a new group of operation columns.
protected  void setPreferredHeadSize()
          Deprecated.  
 void setResourceBundle(java.util.ResourceBundle res)
          Sets the language resource bundle.
 void setSizeColumnListener(TableSorter.ColumnSizeListener columnSizeListener)
          Sets the TableSorter.ColumnSizeListener to this TableSorter.
 void setSourceTable(javax.swing.JTable table)
           
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 void shuttleSort(int[] from, int[] to, int low, int high)
          Fast algorithm to sort an array.
 void sort(java.lang.Object sender)
          Sorts the model.
 void sortByColumn(int column)
          Sorts the table by the columns specified as parameter.
 void sortByColumn(int column, boolean ascending)
          Sorts the table by the columns specified as parameter.
protected  void sortByColumn(int column, boolean ascending, boolean fireEvent)
           
 void swap(int i, int j)
          Swaps two indexes of the table.
 void tableChanged(javax.swing.event.TableModelEvent e)
          Processes the table change events for this model.
 void updateRowData(java.util.Hashtable rowData, java.util.Hashtable keys)
           
 void updateRowData(java.util.Hashtable rowData, java.util.List columns, java.util.Hashtable keys)
           
 void updateRowData(java.util.Hashtable rowData, java.util.Vector keys)
          Updates the information of a row.
 
Methods inherited from class com.ontimize.gui.table.TableMap
getColumnClass, getColumnCount, getColumnName, getModel, setModel
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, 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
 

Field Detail

localSorter

protected boolean localSorter

YEAR

public static final int YEAR
A grouping type configuration parameter

See Also:
Constant Field Values

YEAR_MONTH

public static final int YEAR_MONTH
A grouping type configuration parameter

See Also:
Constant Field Values

YEAR_MONTH_DAY

public static final int YEAR_MONTH_DAY
A grouping type configuration parameter

See Also:
Constant Field Values

QUARTER_YEAR

public static final int QUARTER_YEAR
A grouping type configuration parameter

See Also:
Constant Field Values

QUARTER

public static final int QUARTER
A grouping type configuration parameter

See Also:
Constant Field Values

MONTH

public static final int MONTH
A grouping type configuration parameter

See Also:
Constant Field Values

filterKey

public static final java.lang.String filterKey
Filtering preference key

See Also:
Constant Field Values

groupKey

public static final java.lang.String groupKey
Deprecated.  

Grouping preference key

See Also:
Constant Field Values

DEBUG

public static boolean DEBUG

bundle

public java.util.ResourceBundle bundle

MULTIORDER_PERMIT

public static boolean MULTIORDER_PERMIT
Allows or denies sorting the table by several columns


SUM

public static final int SUM
Grouping operation type

See Also:
Constant Field Values

AVG

public static final int AVG
Grouping operation type

See Also:
Constant Field Values

MAX

public static final int MAX
Grouping operation type

See Also:
Constant Field Values

MIN

public static final int MIN
Grouping operation type

See Also:
Constant Field Values

COUNT

public static final int COUNT
Grouping operation type

See Also:
Constant Field Values

comparator

public static java.text.Collator comparator

indexes

protected int[] indexes

rowsNumberToOrder

protected int rowsNumberToOrder

sortingColumns

protected java.util.Vector sortingColumns

ascendants

protected java.util.Vector ascendants

compares

protected int compares

sourceTable

protected javax.swing.JTable sourceTable

orderEnabled

protected boolean orderEnabled

filterEnabled

protected boolean filterEnabled

sumColumns

protected java.util.Vector sumColumns

operationColumns

protected java.util.Hashtable operationColumns

lastIsSum

protected boolean lastIsSum

rowsNumber

protected int rowsNumber

auxHeadValue

protected java.lang.Object auxHeadValue

sizeColumnListener

protected TableSorter.ColumnSizeListener sizeColumnListener

filterDialog

protected FilterDialog filterDialog

insertingRowData

protected java.util.Hashtable insertingRowData

insertableCols

protected java.util.Vector insertableCols

insertingEnabled

protected boolean insertingEnabled

allowTotalInserting

protected boolean allowTotalInserting

fitHeadSize

protected boolean fitHeadSize
Constructor Detail

TableSorter

public TableSorter(ExtendedTableModel model)
Constructor.

Parameters:
model - the table model

TableSorter

public TableSorter(ExtendedTableModel model,
                   java.util.Vector sumColumns)
Constructor.

Parameters:
model -
sumColumns - columns to which operations can be applied

TableSorter

public TableSorter(ExtendedTableModel model,
                   java.util.Vector sumColumns,
                   java.util.Hashtable params)
Method Detail

isFilterEnabled

public boolean isFilterEnabled()

setFilterDialog

public void setFilterDialog(FilterDialog filterDialog)

getFilterDialog

public FilterDialog getFilterDialog()

setSourceTable

public void setSourceTable(javax.swing.JTable table)

setModel

public void setModel(TableSorter.GroupTableModel model)
Sets a new GroupTableModel to this TableSorter.

Parameters:
model -

compareRowsByColumn

public int compareRowsByColumn(int rowIndex1,
                               int rowIndex2,
                               int columnIndex)
Compares to row values of the same column.

Parameters:
rowIndex1 -
rowIndex2 -
columnIndex -
Returns:
0 if both values are null or equal
-1 if the first value is null or less than the second
1 if the second value is null or less than the first

compare

public int compare(int rowIndex1,
                   int rowIndex2)
Compares two rows column by column, following the sorting of the columns.

Parameters:
rowIndex1 -
rowIndex2 -
Returns:
0 if the rows are equal
1 if the first row has a null or a bigger value than the second
-1 if the first row has a null or a lower value than the second
See Also:
compareRowsByColumn(int, int, int)

reallocateIndexes

public void reallocateIndexes()
Sets up a new array of indexes with the right number of elements for the new data model.


tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Processes the table change events for this model. Reallocates the row indexes and in case rows were added, removed or changed, sorts the model according the new values and the column sorting information.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener
Overrides:
tableChanged in class TableMap

checkModel

public boolean checkModel()
Checks the model to ensure that all the changes in the model have been processed. This means that the Sorting model and the table model are in sync.

Returns:
true if the model is ok, false in case the number of record of the model is different to the number of records of of the sorter.

sort

public void sort(java.lang.Object sender)
Sorts the model.

Parameters:
sender - unused
See Also:
shuttleSort(int[], int[], int, int)

n2sort

public void n2sort()
Deprecated.  

Sorts the table indexes.

See Also:
swap(int, int)

shuttleSort

public void shuttleSort(int[] from,
                        int[] to,
                        int low,
                        int high)
Fast algorithm to sort an array.

Parameters:
from - the original array
to - the sorted array
low - the starting index (typically 0)
high - the ending index (typically from.length)

swap

public void swap(int i,
                 int j)
Swaps two indexes of the table.

Parameters:
i -
j -

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Specified by:
getValueAt in interface javax.swing.table.TableModel
Overrides:
getValueAt in class TableMap

getCalculatedColumnsDependence

protected java.util.Hashtable getCalculatedColumnsDependence(java.lang.String columnName)
Get the columns that exist in the expression to calculate the specified column

Parameters:
columnName - Name of the calculated column
Returns:
a Hashtable which keys are the indices of the columns and values are the colum names

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class TableMap

sortByColumn

public void sortByColumn(int column)
Sorts the table by the columns specified as parameter. The sorting will be ascending.

Parameters:
column - the column that will be used to sort

sortByColumn

public void sortByColumn(int column,
                         boolean ascending)
Sorts the table by the columns specified as parameter.

Parameters:
column - the column that will be used to sort
ascending - if true, the values will go from lower to higher; reverse when true

sortByColumn

protected void sortByColumn(int column,
                            boolean ascending,
                            boolean fireEvent)

free

public void free()
          throws java.lang.Exception
Removes the table header listener and the model.

Specified by:
free in interface Freeable
Throws:
java.lang.Exception

enableSort

public void enableSort(boolean enable)
Enables or disables sorting in the table

Parameters:
enable -

isSortEnabled

public boolean isSortEnabled()
Checks if the sorting is enable.

Returns:
true if sorting is enabled, false otherwise

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class TableMap

deleteRows

public void deleteRows(int[] rowIndex)
Deletes the specified rows from the model

Parameters:
rowIndex - the indexes that identifies the rows to remove

deleteRow

public void deleteRow(int rowIndex)
Deletes the specified row.

Parameters:
rowIndex - the row index

applyFilter

public void applyFilter(int columnIndex,
                        java.lang.Object filter)
Applies a filter to a column.

Parameters:
columnIndex - the index of the column to be filtered
filter - the filter to be applied

lastFilterOr

public boolean lastFilterOr()

applyFilter

public void applyFilter(java.util.Hashtable filters)
Applies a group of filters to the table. Each key of the Hashtable contains the name of the column to be filtered, and the corresponding value will be the filter to apply to that column.

Parameters:
filters - the filters to apply to the table

applyFilter

public void applyFilter(java.util.Hashtable filters,
                        boolean or)
Applies a group of filters to the table. Each key of the Hashtable contains the name of the column to be filtered, and the corresponding value will be the filter to apply to that column.

Parameters:
filters - the filters to apply to the table
or - true to be established OR-condition.

getFilteredColumns

public java.util.Vector getFilteredColumns()
Returns the columns that are being filtered.

Returns:
the filtered columns' names

fireTableChanged

public void fireTableChanged(javax.swing.event.TableModelEvent e)
Method fired to update the table after a sorting.


resetFilter

public void resetFilter()
Removes all the filters from the table.


resetFilter

public void resetFilter(java.lang.String columnName)
Removes the filters from the column specified by its name.

Parameters:
columnName - the column name

resetFilter

public void resetFilter(int columnIndex)
Removes the filters from the column specified by its index.

Parameters:
columnIndex - the column index

resetOrder

public void resetOrder()
Removes the sorting applied to the table.


resetOrder

public void resetOrder(int columnIndex)
Removes the sorting applied to the column specified by its index.

Parameters:
columnIndex - the column index

isSorted

public boolean isSorted(int columnIndex)
Determines whether a column is sorted or not.

Parameters:
columnIndex -
Returns:
true is the column is sorted, false otherwise

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel
Overrides:
getRowCount in class TableMap

getCalculatedColumns

public java.util.Hashtable getCalculatedColumns()
Returns the columns that have a calculated expression and the expression.

Returns:
a Hashtable which keys are the column names of the the columns that have a calculated expression set, and which values are the corresponding calculates expression to each column

getCalculatedColumnsName

public java.util.Vector getCalculatedColumnsName()
Returns the names of the columns that have a calculated expression set.

Returns:
a vector with the column names

getRequiredColumnsToCalculatedColumns

public java.util.Vector getRequiredColumnsToCalculatedColumns()

getCalculatedValue

public java.lang.Object getCalculatedValue(int column,
                                           java.util.Hashtable rowValues)

getCalculatedColumnExpression

public java.lang.String getCalculatedColumnExpression(java.lang.String columnName)
Returns the column expression for the specified column name.

Parameters:
columnName - the column name
Returns:
the expression corresponding to the column name passed as parameter; null if no expression set

setCalculatedColumnExpression

public void setCalculatedColumnExpression(java.lang.String columnName,
                                          java.lang.String expression)
Sets a calculated expression to a colum.

Parameters:
columnName - the column name
expression - the calculated expression

getRowData

public java.util.Hashtable getRowData(int rowIndex)
Returns the information contained in the specified row.

Parameters:
rowIndex - the row
Returns:
a Hashtable containing the information corresponding to the row, where the Hashtable keys are the columns of the table, and the values are the values for the specified row

getRowDataForKeys

public java.util.Hashtable getRowDataForKeys(java.util.List keys,
                                             java.util.Hashtable keysValues)

getGroupedRowData

public java.util.Hashtable getGroupedRowData(int rowIndex)
Returns the information contained in the specified row, in case that the table is grouped. When grouping, several model rows can be grouped into a single row. This method returns all the model information for the rows, even if the rows are grouped.

Parameters:
rowIndex - the row index
Returns:
the values corresponding to the grouped index; when the table is grouped, the keys are the column names, and because several rows can be grouped, the value is a Vector with the values for the corresponding rows

getCalculatedRowData

public java.util.Hashtable getCalculatedRowData(int rowIndex)
Returns a Hashtable with the information of the calculated columns for this row.

Parameters:
rowIndex -
Returns:
the Hashtable keys are the calculated columns names and the values are the corresponding calculated values.

enableFiltering

public void enableFiltering(boolean enable)
Enables or disables that filteringcan be applied to the table.

Parameters:
enable -

updateRowData

public void updateRowData(java.util.Hashtable rowData,
                          java.util.Vector keys)
Updates the information of a row. The Hashtable contains the new information where the keys are the column names and the values the corresponding ones for each column. The columns Vector specifies the columns that are keys, that is, determines the row to be updated. Also the values for the keys are stored in the Hashtable. The other columns in the Hashtable that are not keys will have the values to update.

Parameters:
rowData - the row information
keys - the columns that are keys and so identifies each row

updateRowData

public void updateRowData(java.util.Hashtable rowData,
                          java.util.Hashtable keys)

updateRowData

public void updateRowData(java.util.Hashtable rowData,
                          java.util.List columns,
                          java.util.Hashtable keys)

addRow

public void addRow(java.util.Hashtable rowData)
Adds a new row to the model.

Parameters:
rowData - a Hashtable containing the information for the new row, when the keys are the columns names and the values the corresponding value for each column.

addRow

public void addRow(int viewRowIndex,
                   java.util.Hashtable rowData)
Adds a new row in the position specified.

Parameters:
viewRowIndex - the position that will have the row in the view
rowData - a Hashtable containing the information for the new row, when the keys are the columns names and the values the corresponding value for each column.

addRows

public void addRows(int[] viewRowIndex,
                    java.util.Vector rowData)
Deprecated.  

The Vector contains Hashtables, each one stores the information of the column, this is, the keys are the column names and the values the values for each column. Each hashtable corresponds to a table row. If the table is grouped, grouping is removed.

Parameters:
viewRowIndex - unused
rowData -
See Also:
addRows(Vector)

addRows

public void addRows(java.util.Vector rowData)
The Vector contains Hashtables, each one stores the information of the column, this is, the keys are the column names and the values the values for each column. Each hashtable corresponds to a table row. If the table is grouped, grouping is removed. Adds several rows to the table model.

Parameters:
rowData -

setResourceBundle

public void setResourceBundle(java.util.ResourceBundle res)
Description copied from interface: Internationalization
Sets the language resource bundle. When the application changes the configured language, for all the objects that implement this interface this method must be called with the new file.
The method must translate all the elements that have texts in the GUI

Specified by:
setResourceBundle in interface Internationalization
Parameters:
res - the new language bundle.

getTextsToTranslate

public java.util.Vector getTextsToTranslate()
Description copied from interface: Internationalization
Returns all the texts in the element suitable for being translated.

Specified by:
getTextsToTranslate in interface Internationalization
Returns:
all the texts in the element suitable for being translated.

setComponentLocale

public void setComponentLocale(java.util.Locale l)
Specified by:
setComponentLocale in interface Internationalization

isFiltered

public boolean isFiltered(int columnIndex)
Determines whether the specified column us grouped or not.

Parameters:
columnIndex - the index of the column to check
Returns:
true if the column is grouped, false otherwise

convertRowIndexToModel

public int convertRowIndexToModel(int viewRowIndex)
Converts the view index into the corresponding model index. The view index might not be the same as the model index because of the sorting and the grouping operations that can be performed in the table view.

Parameters:
viewRowIndex - the index of the row in the view
Returns:
the model index corresponding to view index passed as parameter;
-1 in case no match exist

convertRowIndexToFilteredModel

public int convertRowIndexToFilteredModel(int viewRowIndex)
Converts the view index to the corresponding index in the filtered model. The view index might not be the same as the filtered model index because of the sorting and the grouping operations that can be performed in the table view.

Parameters:
viewRowIndex - the index of the row in the view
Returns:
the index of the view row index in the FilterTableModel

setData

public void setData(java.util.Hashtable data)
Sets a new group of data to the model. The Hashtable containing the data will have as keys the column names and as values, a vector containing one value per row.

Parameters:
data -

getColumnSum

public java.lang.Number getColumnSum(java.lang.Object columnName)
Sums all the values for a specified column.

Parameters:
columnName -
Returns:
the sum of the values, or null in case the column does not exist

getSelectedColumnOperation

protected java.util.Hashtable getSelectedColumnOperation(int[] rowIndex)
For each column that has an operation configured, returns the result of perform the operation in the rows passed as parameter.

Parameters:
rowIndex - the row indexes
Returns:
a Hashtable where the keys are the operation columns, and the values the result of performing the configured operation in the selected rows
See Also:
getSelectedColumnOperation(Object, int[])

getSelectedColumnOperation

protected java.lang.Number getSelectedColumnOperation(java.lang.Object columnName,
                                                      int[] rowIndex)
Returns the result of the application of the configured operation (sum, maximum, etc.) to the rows passed as parameter for the specified column.

Parameters:
columnName -
rowIndex -
Returns:
the result of the operation applied to the column restricted by the rows passed as parameter; null if the column does not exist

getOperationColumn

public java.lang.Number getOperationColumn(java.lang.Object columnName)
Returns the value of the operation applied to the specified column.

Parameters:
columnName - the name of the column
Returns:
the result of performing the operation in the column
See Also:
getColumnOperation(int)

getColumnType

protected java.lang.Object getColumnType(java.lang.Object columnName)
Returns the operation configured for a column.

Parameters:
columnName -
Returns:
the configured operation, or null if the operation does not exist.

getColumnOperation

protected java.lang.Object getColumnOperation(java.lang.String columnIdentifier,
                                              java.lang.String operation)

getColumnOperation

protected java.lang.Number getColumnOperation(int columnIndex)

getColumnSum

protected java.lang.Number getColumnSum(int modelColumnIndex,
                                        boolean average)
Calculates the sum or the average for a column.

Parameters:
modelColumnIndex - the index of the column to calculate the operation
average - if false, the total value; otherwise, the average value
Returns:
the sum or the average value of the column

getColumnSum

protected java.lang.Number getColumnSum(int columnIndex,
                                        boolean average,
                                        int[] rowIndexes)
Calculates the sum or the average value for a column; only the values of the specified rows will be used.

Parameters:
columnIndex - the column
average - if true, returns the average value; otherwise, returns the sum
rowIndexes - the rows that will be used in the calculus
Returns:

getMaximumMinimumColumn

protected java.lang.Number getMaximumMinimumColumn(int index,
                                                   boolean max)

isSum

public boolean isSum()
Determines whether exists sum columns in the model. Sum columns are special columns that are calculated in the model, and came from operations between other columns.

Returns:
true if sum column exits, false if not.

isSumCell

public boolean isSumCell(int rowIndex,
                         int colIndex)
Determines whether a cell belongs to a sumrow or not. Sumrow are rows that operates with the information contained in the column, and display as result, for example, the sum of all the values of the column.

Parameters:
rowIndex - the row index
colIndex - the column index
Returns:
true if the cell is a sumrow, false otherwise

isSumRow

public boolean isSumRow(int rowIndex)
Determines whether a row is a sumrow, that is, is a row that displays the result of performing operations with the columns. Not all the cells in a row are sumcells.

Parameters:
rowIndex -
Returns:
true if the row has some sumcell, false otherwise

isInsertingRow

public boolean isInsertingRow(int row)

getSumCellRenderer

public javax.swing.table.TableCellRenderer getSumCellRenderer(boolean currency)
Provides a renderer for the rum row. In the information to display is monetary, a cell renderer with currency features can be retrieved.

Parameters:
currency - if true, the renderer accounts for currency information; if false, renders numbers
Returns:
the renderer

fireSizeColumnToFit

public void fireSizeColumnToFit(int columnIndex)
Fires a TableSorter.ColumnSizeEvent to be processed by the TableSorter.ColumnSizeListener configured in the model.

Parameters:
columnIndex - the column that produces the event

setSizeColumnListener

public void setSizeColumnListener(TableSorter.ColumnSizeListener columnSizeListener)
Sets the TableSorter.ColumnSizeListener to this TableSorter.

Parameters:
columnSizeListener -

isFiltered

public boolean isFiltered()
Determines whether the model is filtered or not.

Returns:
true if the model is filtered, false otherwise

getShownValue

public java.util.Hashtable getShownValue()
Returns the information contained in the model but the sumrows.

Returns:
the information in the view, what the client is seeing , where the keys are the column names and the values a vector with the information of each column, as it is stored in the model.

getShownValue

public java.util.Hashtable getShownValue(java.lang.String[] cols)

getData

public java.util.Hashtable getData()
Returns all the information stored in the model, including the calculated columns.

Returns:
the information in the model

getFilteredData

public java.util.Hashtable getFilteredData()
Returns the data contained in the model but according to the filters that are being applied to that model

Returns:
the filtered information

getCurrentRowCount

public int getCurrentRowCount()
Returns the index of the sumrow

Returns:
the index of the sum row

getRealRecordNumber

public int getRealRecordNumber()
Returns the number of records or rows that are actually stored in the model.

Returns:
the real number of rows contained by the model

setEditableColumn

public void setEditableColumn(java.lang.String columnName)
Allows a column to be editable, that is, sets a editor to the column in order that the column value can be editable from the GUI.

Parameters:
columnName - the column name to be editable

setEditableColumn

public void setEditableColumn(java.lang.String columnName,
                              boolean editable)
Configures a column to be editable or not.

Parameters:
columnName - the column name
editable - if true, the column could be edited from the GUI; if false, the column can't be edited from the GUI

getColumnIdentifier

public java.lang.Object getColumnIdentifier(int modelColumnIndex)
Returns the column name that corresponds to a specified index.

Parameters:
modelColumnIndex - the column index
Returns:
the corresponding column name

getColumnsText

public java.util.Vector getColumnsText()
Returns the column texts.

Returns:
the column texts

getColumnNames

public java.util.Vector getColumnNames()
Returns the column names.

Returns:
the column names

addColumn

public void addColumn(java.lang.String columnName)
Adds a new column to the model.

Parameters:
columnName - the new column name

addCalculatedColumn

public void addCalculatedColumn(java.lang.String columnName,
                                java.lang.String expression)

deleteColumn

public void deleteColumn(java.lang.String columnName)
Deletes a column from the model.

Parameters:
columnName -

deleteCalculatedColumn

public void deleteCalculatedColumn(java.lang.String columnName)

group

public void group(int modelColumnIndex)
Groups the model by a column. The grouping will be by year, assuming that the column is a date column.

Parameters:
modelColumnIndex -

group

public void group(int modelColumnIndex,
                  int type)
Groups the model by a column and using a concrete grouping approach. Types are defined in the TableSorter class, and can be at least:

Parameters:
modelColumnIndex - the column used to group the table
type - the column type

setGroupedColumnFunction

public void setGroupedColumnFunction(int modelColumnIndex,
                                     int function)
Applies a function to a column. Types are defined in the TableSorter class, and can be at least:

Parameters:
modelColumnIndex -
function -

getGroupedColumnFunction

public int getGroupedColumnFunction(int modelColumnIndex)
Provides the function applied to the specified column

Parameters:
modelColumnIndex - the column index
Returns:
the operation type
  • SUM
  • AVG
  • MAX
  • MIN
  • COUNT

resetGroup

public void resetGroup()
Deletes all the grouping in the table.


isGrouped

public boolean isGrouped(int col)
Determines whether a column is grouped or not.

Parameters:
col -
Returns:

isGrouped

public boolean isGrouped()
Determines whether the table has a grouping applied or not.

Returns:

setOperationColumns

public void setOperationColumns(java.util.Hashtable operationColumns)
Sets a new group of operation columns.

Parameters:
operationColumns - the new operation columns configuration, where the keys determines the column names and the values are the operations to be applied to those columns.

isAscending

public boolean isAscending()
Determines whether the first sorting in the table is ascending or descending.

Returns:
true if the first ordenation in the table is ascending; false otherwise

isAscending

public boolean isAscending(int columnIndex)
Determines whether a column sorting is ascending or not.

Parameters:
columnIndex -
Returns:

setFitHeadSize

public void setFitHeadSize(boolean fit)
Configures the table to auto adjust the header size.

Parameters:
fit -

setPreferredHeadSize

protected void setPreferredHeadSize()
Deprecated.  


getFilters

public java.util.Hashtable getFilters()
Returns the filters for the table.

Returns:

getColumnFilter

public java.lang.Object getColumnFilter(java.lang.String columnName)
Returns the filters applied to a column.

Parameters:
columnName -
Returns:

isSorted

public boolean isSorted()
Determines whether the table is being sorted or not.

Returns:
true if the table is being sorted; false otherwise.

getFirstSortedColumn

public int getFirstSortedColumn()
Returns the index of the first sorted column.

Returns:
the index of the first sorted column, -1 if no sorting exists.

getSortingColumns

public int[] getSortingColumns()
Returns the indexes of all the columns that has a sorting in the table, following the sorting order.

Returns:
the indexes of the sorting columns, in order; if no indexes are being applied, returns an empty array.

getAscendent

public boolean[] getAscendent()
Returns the indexes of all the columns that has an ascending sorting in the table, following the sorting order.

Returns:
the indexes of the sorting columns, in the order the are being applied; if no indexes are being applied, returns an empty array.

setFilterValidator

public void setFilterValidator(TableSorter.FilterValidator filterValidator)
Sets a TableSorter.FilterValidator to the model.

Parameters:
filterValidator - the filter validator

getFilterValidator

public TableSorter.FilterValidator getFilterValidator()
Returns the filter validator configured in the model.

Returns:
the current filter validator

getOperationColumn

public java.util.Hashtable getOperationColumn()
Returns the current operation columns.

Returns:
the current operation columns, where the keys are the column names, and the values the operations performed in each column.

setInsertEnabled

public void setInsertEnabled(boolean enabled)
Enable or disable the inserting row

Parameters:
enabled -

isInsertingEnabled

public boolean isInsertingEnabled()

getInsertingData

public java.util.Hashtable getInsertingData()

clearInsertingRow

public void clearInsertingRow(java.util.Hashtable parentkeys)

isLocalSorter

public boolean isLocalSorter()
Checks if the sorter is local. If the table is pageable the sorter is implemented via a SQL statements.

Returns:

setLocalSorter

public void setLocalSorter(boolean localSorter)

Ontimize