JIDE 3.5.15

com.jidesoft.grid
Class TableModelWrapperUtils

java.lang.Object
  extended by com.jidesoft.grid.TableModelWrapperUtils

public class TableModelWrapperUtils
extends Object

TableWrapperUtils is a utility class that contains several useful methods for TableModelWrapper.


Constructor Summary
TableModelWrapperUtils()
           
 
Method Summary
static int getActualColumnAt(TableModel outerModel, int column)
          Gets the actual column index on the innermost model according to the column index on the outerModel.
static int getActualColumnAt(TableModel outerModel, int column, Class innerModelClass)
          Gets the actual column index on an inner model whose class is the innerModelClass.
static int getActualColumnAt(TableModel outerModel, int column, TableModel innerModel)
          Gets the actual column index on the innerModel according to the column index on the outerModel.
static int getActualColumnCount(TableModel outerModel)
          Gets the innermost table model column count.
static int[] getActualColumnsAt(TableModel outerModel, int[] columnIndices, boolean sort)
          Gets the actual columns on the innermost table model based on the column indices on the outer TableModel.
static int getActualRowAt(TableModel outerModel, int rowIndex)
          Gets the actual row index on the innermost model according to the rowIndex on the outerModel.
static int getActualRowAt(TableModel outerModel, int rowIndex, Class innerModelClass)
          Gets the actual row index on an innerModel whose class is innerModelClass according to the rowIndex on the outerModel.
static int getActualRowAt(TableModel outerModel, int rowIndex, TableModel innerModel)
          Gets the actual row index on the innerModel according to the rowIndex on the outerModel.
static int getActualRowCount(TableModel outerModel)
          Gets the innermost table model row count.
static int[] getActualRowsAt(TableModel outerModel, int[] rowIndices, boolean sort)
          Gets the actual rows index on the inner most table model based on the row indices of the outer TableModel.
static TableModel getActualTableModel(TableModel outerModel)
          Gets the inner most table model.
static TableModel getActualTableModel(TableModel outerModel, Class innerModelClass)
          Gets the inner table model whose class is an instance of the innerModelClass.
static int getColumnAt(TableModel outerModel, int columnInInnerModel)
          Gets the column index on the outer model knowing the column index on the innermost model
static int getColumnAt(TableModel outerModel, TableModel innerModel, int columnInInnerModel)
          Gets the column index on the outer model knowing the column index on an inner model
static int[] getColumnsAt(TableModel outerModel, int[] columnIndices, boolean sort)
          Gets the visual column array based on the column indices on the inner TableModel.
static TableModel getNextInnerTableModel(TableModel outerModel)
          Gets next inner table model.
static int getRowAt(TableModel outerModel, int rowInInnerModel)
          Gets the row index on the outer model knowing the row index on the innermost model
static int getRowAt(TableModel outerModel, TableModel innerModel, int rowInInnerModel)
          Gets the row on the outer model knowing the row index on an inner model
static int[] getRowsAt(TableModel outerModel, int[] rowIndices, boolean sort)
          Gets the visual rows on the outerModel based on the row indices on the innermost TableModel.
static int getVisibleChildrenCount(TableModel model, Row parent)
          Deprecated. replaced by TreeTableUtils.getDescendantCount(javax.swing.table.TableModel, Row, boolean, boolean)
static int getVisibleChildrenCount(TableModel model, Row parent, boolean leafOnly, boolean countCollapsedNodes)
          Deprecated. replaced by TreeTableUtils.getDescendantCount(javax.swing.table.TableModel, Row, boolean, boolean)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableModelWrapperUtils

public TableModelWrapperUtils()
Method Detail

getActualTableModel

public static TableModel getActualTableModel(TableModel outerModel,
                                             Class innerModelClass)
Gets the inner table model whose class is an instance of the innerModelClass.

Parameters:
outerModel - the outermost TableModel
innerModelClass - the class for the inner model.
Returns:
the table model whose class is innerModelClass.

getActualTableModel

public static TableModel getActualTableModel(TableModel outerModel)
Gets the inner most table model.

Parameters:
outerModel - the outer TableModel
Returns:
the innermost table model. It is the first inner model that is not an instance of TableModelWrapper.

getNextInnerTableModel

public static TableModel getNextInnerTableModel(TableModel outerModel)
Gets next inner table model.

Parameters:
outerModel - the outer TableModel
Returns:
the next inner table model.

getActualRowAt

public static int getActualRowAt(TableModel outerModel,
                                 int rowIndex,
                                 Class innerModelClass)
Gets the actual row index on an innerModel whose class is innerModelClass according to the rowIndex on the outerModel.

Parameters:
outerModel - the outer TableModel.
rowIndex - the row index on the outer TableModel
innerModelClass - the class of the inner TableModel
Returns:
the row index on inner TableModel. If it can't find it, -1 will be returned.

getActualRowAt

public static int getActualRowAt(TableModel outerModel,
                                 int rowIndex,
                                 TableModel innerModel)
Gets the actual row index on the innerModel according to the rowIndex on the outerModel.

Parameters:
outerModel - the outer TableModel.
rowIndex - the row index on the outer TableModel
innerModel - the inner TableModel
Returns:
the row index on inner TableModel. If it can't find it, -1 will be returned.

getActualRowAt

public static int getActualRowAt(TableModel outerModel,
                                 int rowIndex)
Gets the actual row index on the innermost model according to the rowIndex on the outerModel.

Parameters:
outerModel - the outer TableModel.
rowIndex - the row index on the outer TableModel
Returns:
the row index on innermost model which is not a table wrapper. If it can't find it, -1 will be returned.

getActualRowCount

public static int getActualRowCount(TableModel outerModel)
Gets the innermost table model row count.

Parameters:
outerModel - the outer TableModel
Returns:
the row count on the innermost model.

getRowAt

public static int getRowAt(TableModel outerModel,
                           TableModel innerModel,
                           int rowInInnerModel)
Gets the row on the outer model knowing the row index on an inner model

Parameters:
outerModel - the outer TableModel
innerModel - the inner TableModel
rowInInnerModel - the row index on the inner TableModel
Returns:
the row index on the outer model. If it can't find it, -1 will be returned.

getRowAt

public static int getRowAt(TableModel outerModel,
                           int rowInInnerModel)
Gets the row index on the outer model knowing the row index on the innermost model

Parameters:
outerModel - the outer TableModel
rowInInnerModel - the row index on the innermost TableModel
Returns:
the row index on the outer model. If it can't find it, -1 will be returned.

getActualColumnAt

public static int getActualColumnAt(TableModel outerModel,
                                    int column,
                                    Class innerModelClass)
Gets the actual column index on an inner model whose class is the innerModelClass.

Parameters:
outerModel - the outer TableModel.
column - the column index on outer TableModel
innerModelClass - the class of the inner TableModel
Returns:
the column index on inner TableModel. If it can't find it, -1 will be returned.

getActualColumnAt

public static int getActualColumnAt(TableModel outerModel,
                                    int column,
                                    TableModel innerModel)
Gets the actual column index on the innerModel according to the column index on the outerModel.

Parameters:
outerModel - the outer TableModel.
column - the column index on outer TableModel
innerModel - the inner TableModel
Returns:
the column index on inner TableModel. If it can't find it, -1 will be returned.

getActualColumnAt

public static int getActualColumnAt(TableModel outerModel,
                                    int column)
Gets the actual column index on the innermost model according to the column index on the outerModel.

Parameters:
outerModel - the outer TableModel.
column - the column index on outer TableModel
Returns:
the column index on innermost model which is not a table wrapper. If it can't find it, -1 will be returned.

getActualColumnCount

public static int getActualColumnCount(TableModel outerModel)
Gets the innermost table model column count.

Parameters:
outerModel - the outer TableModel
Returns:
the column count on the innermost model.

getColumnAt

public static int getColumnAt(TableModel outerModel,
                              TableModel innerModel,
                              int columnInInnerModel)
Gets the column index on the outer model knowing the column index on an inner model

Parameters:
outerModel - the outer TableModel
innerModel - the inner model
columnInInnerModel - the column index on the inner model.
Returns:
the column index on the outer model. If it can't find it, -1 will be returned.

getColumnAt

public static int getColumnAt(TableModel outerModel,
                              int columnInInnerModel)
Gets the column index on the outer model knowing the column index on the innermost model

Parameters:
outerModel - the outer TableModel
columnInInnerModel - the column index on the innermost model
Returns:
the column index on the outer model. If it can't find it, -1 will be returned.

getActualRowsAt

public static int[] getActualRowsAt(TableModel outerModel,
                                    int[] rowIndices,
                                    boolean sort)
Gets the actual rows index on the inner most table model based on the row indices of the outer TableModel. This method can be used in combination with table.getSelectedRows() which returns an int array to find out the actual row indices on the actual table model.

Parameters:
outerModel - the outer TableModel.
rowIndices - the row index array on the outer TableModel
sort - true to sort the returned row indices. If false, the order will be the same as the order of the rowIndices parameter.
Returns:
the row index array on nested model which is not a table wrapper. If it can't find any row, -1 will be placed on the index of the array.

getActualColumnsAt

public static int[] getActualColumnsAt(TableModel outerModel,
                                       int[] columnIndices,
                                       boolean sort)
Gets the actual columns on the innermost table model based on the column indices on the outer TableModel. This method can be used in combination with table.getSelectedColumns() which returns an int array to find out the actual column indices on the actual table model.

Parameters:
outerModel - the outer TableModel.
columnIndices - the column index array on the outer TableModel
sort - true to sort the returned column indices. If false, the order will be the same as the order of the columnIndices parameter.
Returns:
the column index array on nested model which is not a table wrapper. If it can't find any row, -1 will be placed on the index of the array.

getRowsAt

public static int[] getRowsAt(TableModel outerModel,
                              int[] rowIndices,
                              boolean sort)
Gets the visual rows on the outerModel based on the row indices on the innermost TableModel. This method can be used in combination with table.getSelectedRows() which returns an int array to find out the row indices in the outerModel.

Parameters:
outerModel - the outer TableModel.
rowIndices - the row index array on the innermost TableModel
sort - true to sort the returned row indices. If false, the order will be the same as the order of the rowIndices parameter.
Returns:
the row index array on the outer model. If it can't find any row, -1 will be placed on the index of the array.

getColumnsAt

public static int[] getColumnsAt(TableModel outerModel,
                                 int[] columnIndices,
                                 boolean sort)
Gets the visual column array based on the column indices on the inner TableModel.

Parameters:
outerModel - the outer TableModel.
columnIndices - the column index array of the innermost TableModel
sort - true to sort the returned column indices. If false, the order will be the same as the order of the columnIndices parameter.
Returns:
the column index array on the outer model. If it can't find any row, -1 will be placed on the index of the array.

getVisibleChildrenCount

@Deprecated
public static int getVisibleChildrenCount(TableModel model,
                                                     Row parent,
                                                     boolean leafOnly,
                                                     boolean countCollapsedNodes)
Deprecated. replaced by TreeTableUtils.getDescendantCount(javax.swing.table.TableModel, Row, boolean, boolean)

The method can only be used for any table model who has one inner model as TreeTableModel to find the current visible children count. It has two options, leaf only or count collapsed nodes.

It could hit performance since we have to expand all to count the actual leaf nodes then set the original expansion state back.

Parameters:
model - the outer table model
parent - the Row to be queried
leafOnly - the count will only include leaf children or not
countCollapsedNodes - if the collapsed nodes need to be counted
Returns:
the visible children count in the outer table model

getVisibleChildrenCount

@Deprecated
public static int getVisibleChildrenCount(TableModel model,
                                                     Row parent)
Deprecated. replaced by TreeTableUtils.getDescendantCount(javax.swing.table.TableModel, Row, boolean, boolean)

The method can only be used for any table model who has one inner model as TreeTableModel to find the current visible children count.

Parameters:
model - the outer table model
parent - the Row to be queried
Returns:
the visible children count in the outer table model

JIDE 3.5.15