|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel com.jidesoft.grid.TableModelWrapperImpl com.jidesoft.grid.DefaultTableModelWrapper com.jidesoft.grid.SortableTableModel com.jidesoft.grid.SortableTreeTableModel<T>
public class SortableTreeTableModel<T extends Row>
A sortable TreeTableModel used by TreeTable. If the TreeTable is sortable, it will use this model by default.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.jidesoft.grid.SortableTableModel |
---|
SortableTableModel.ColumnComparatorContextProvider, SortableTableModel.SortOrderHandler |
Nested classes/interfaces inherited from interface com.jidesoft.grid.ISortableTableModel |
---|
ISortableTableModel.SortItem |
Field Summary | |
---|---|
TableModel |
_actualTableModel
|
static int |
SORTABLE_ALL_LEVELS
|
static int |
SORTABLE_LEAF_LEVEL
|
static int |
SORTABLE_NON_LEAF_LEVEL
|
static int |
SORTABLE_NON_ROOT_LEVEL
|
static int |
SORTABLE_NONE
|
static int |
SORTABLE_ROOT_LEVEL
|
Fields inherited from class com.jidesoft.grid.SortableTableModel |
---|
_sortItemSupport |
Fields inherited from class com.jidesoft.grid.DefaultTableModelWrapper |
---|
_indexes |
Fields inherited from class com.jidesoft.grid.TableModelWrapperImpl |
---|
_model |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Fields inherited from interface com.jidesoft.grid.ISortableTableModel |
---|
SORT_PRIORITY_FIFO, SORT_PRIORITY_FILO |
Fields inherited from interface com.jidesoft.grid.MultiTableModel |
---|
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN |
Fields inherited from interface com.jidesoft.grid.EditorStyleTableModel |
---|
EDITOR_STYLE_EDITABLE, EDITOR_STYLE_NORMAL, EDITOR_STYLE_READ_ONLY, EDITOR_STYLE_SELECT_ONLY |
Constructor Summary | |
---|---|
SortableTreeTableModel(TableModel model)
|
Method Summary | |
---|---|
protected int[] |
append(int firstRow,
int lastRow)
|
protected void |
cacheComparators()
For performance, all comparators for each column should be cached first. |
protected int |
compare(int row1,
int row2)
Compares two rows to decide the order. |
int |
compare(int rowIndex1,
int rowIndex2,
int column)
Compares the two cell values at the two rows. |
int |
getDefaultSortableOption()
Gets the default sortable option. |
Object |
getRoot()
Gets the root expandable row which has the original rows as children. |
Row |
getRowAt(int rowIndex)
Returns the row at row specified by row . |
int |
getRowIndex(T row)
Gets the index of the row. |
int |
getSortableOption(int column)
Gets the sortable option for the specified column. |
List<ISortableTableModel.SortItem> |
getSortingColumns()
Gets the sorting columns. |
protected Object |
getValueAt(Row row,
int column)
Gets the value at the column in the Row |
void |
setDefaultSortableOption(int defaultSortableOption)
Sets the sortable option. |
void |
setSortableOption(int column,
int sortableOption)
Sets the sortable option for the specified column. |
protected boolean |
shouldCompare(int sortableOption,
Row row1,
Row row2,
boolean root,
boolean leaf1,
boolean leaf2,
int column)
In a tree, there are cases if two nodes should be compared. |
protected void |
sort()
Sorts the table model. |
Methods inherited from class com.jidesoft.grid.TableModelWrapperImpl |
---|
addIndexChangeListener, createCompoundTableModelEvent, fireTableCellsUpdated, getActualModel, getCellStyleAt, getColumnClass, getColumnCount, getColumnIdentifier, getColumnName, getColumnType, getIndexChangeListeners, getTableIndex, isCellSpanOn, isCellStyleOn, isNavigableAt, isNavigationOn, removeIndexChangeListener |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.jidesoft.grid.ISortableTableModel |
---|
getActualRowAt |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from interface com.jidesoft.grid.TableModelWrapper |
---|
getActualModel |
Field Detail |
---|
public static final int SORTABLE_NONE
public static final int SORTABLE_ROOT_LEVEL
public static final int SORTABLE_LEAF_LEVEL
public static final int SORTABLE_NON_ROOT_LEVEL
public static final int SORTABLE_NON_LEAF_LEVEL
public static final int SORTABLE_ALL_LEVELS
public TableModel _actualTableModel
Constructor Detail |
---|
public SortableTreeTableModel(TableModel model)
Method Detail |
---|
protected void cacheComparators()
SortableTableModel
cacheComparators
in class SortableTableModel
public List<ISortableTableModel.SortItem> getSortingColumns()
SortableTableModel
getSortingColumns
in interface ISortableTableModel
getSortingColumns
in class SortableTableModel
protected void sort()
SortableTableModel
sort
in class SortableTableModel
protected int compare(int row1, int row2)
SortableTableModel
compare
in class SortableTableModel
row1
- index of the first row to be comparedrow2
- index of the second row to be compared
public int compare(int rowIndex1, int rowIndex2, int column)
SortableTableModel
compare
in class SortableTableModel
rowIndex1
- index of the first row to be comparedrowIndex2
- index of the second row to be comparedcolumn
- the column index of both rows.
protected boolean shouldCompare(int sortableOption, Row row1, Row row2, boolean root, boolean leaf1, boolean leaf2, int column)
setDefaultSortableOption(int)
and setSortableOption(int,int)
method so that you can set a default sortable option or set different sortable
option for each column.
Here is the default implementation.
return (root && sortableOption == SORTABLE_ROOT_LEVEL)
|| (!root && sortableOption == SORTABLE_NON_ROOT_LEVEL)
|| (leaf1 && leaf2 && sortableOption == SORTABLE_LEAF_LEVEL)
|| (!leaf1 && !leaf2 && sortableOption == SORTABLE_NON_LEAF_LEVEL)
|| sortableOption == SORTABLE_ALL_LEVELS;
If returning false, we will not compare the rows when sorting. Understanding that this default implementation may
not be good enough, we made this method protected so that you can subclass and provide your own way to decide if
you want to compare the two rows.
sortableOption
- the sortable option. If you didn't call setSortableOption(int,int)
on any column,
this value will be the defaultSortableOption.row1
- the first row indexrow2
- the second row indexroot
- whether the two nodes' parent is the root node.leaf1
- whether the first node is a leaf node.leaf2
- whether the second node is a leaf node.column
- the column that will be compared.
protected Object getValueAt(Row row, int column)
row
- the row instancecolumn
- the column index
public int getDefaultSortableOption()
SORTABLE_ALL_LEVELS
, SORTABLE_LEAF_LEVEL
,SORTABLE_ROOT_LEVEL
or SORTABLE_NONE
.
public void setDefaultSortableOption(int defaultSortableOption)
setSortableOption(int,int)
method is used called.
defaultSortableOption
- Valid sortable options are SORTABLE_ALL_LEVELS
, SORTABLE_LEAF_LEVEL
,SORTABLE_ROOT_LEVEL
or SORTABLE_NONE
.public void setSortableOption(int column, int sortableOption)
column
- the column index in table model. It's not the visual index but the model index.sortableOption
- Valid sortable options are SORTABLE_ALL_LEVELS
, SORTABLE_LEAF_LEVEL
,SORTABLE_ROOT_LEVEL
, SORTABLE_NON_LEAF_LEVEL
,
SORTABLE_NON_ROOT_LEVEL
or SORTABLE_NONE
.public int getSortableOption(int column)
SORTABLE_ALL_LEVELS
,
SORTABLE_LEAF_LEVEL
,SORTABLE_ROOT_LEVEL
or SORTABLE_NONE
. The sortable option set
using this method will overwrite the value set by setDefaultSortableOption(int)
.
column
- the column index in table model. It's not the visual index but the model index.
protected int[] append(int firstRow, int lastRow)
append
in class SortableTableModel
public Row getRowAt(int rowIndex)
row
.
getRowAt
in interface ITreeTableModel<T extends Row>
rowIndex
- the row whose row is to be queried
public int getRowIndex(T row)
getRowIndex
in interface ITreeTableModel<T extends Row>
row
- row
public Object getRoot()
ITreeTableModel
getRoot
in interface ITreeTableModel<T extends Row>
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |