| java.lang.Object javax.swing.table.AbstractTableModel snow.sortabletable.SortableTableModel
SortableTableModel | public class SortableTableModel extends AbstractTableModel (Code) | | Wraps a basic model and allow sorting of his columns
the basic model remains unchanged. Only this model is sorted !
Features :
+ The selection is maintained after table updates.
+ Can installGUI() without corrupting model/view separation
usage:
1) make a FineGrain table model (like AbstractTableModel...)
2) make this class, pass 1)
3) make a table with this model 2)
4) call installGUI() with the table 3) to allow sorting
|
Constructor Summary | |
public | SortableTableModel(FineGrainTableModel basicTableModel) wraps a sortable feature around your basic table model
Easy usage:
1) just create your model, pass it here
2) use this model as tablemodel for your jtable. | public | SortableTableModel(FineGrainTableModel basicTableModel, int sortedColumn, boolean ascending) wraps a sortable feature around your basic table model
Easy usage:
1) just create your model, pass it here
2) use this model as tablemodel for your jtable. |
Method Summary | |
public synchronized void | advancedSearch(String str1, String str2, boolean andSearch, boolean useRegEx, int column) | protected Icon | getAscIcon(int column) returns the ascending/descending sort icons. | public FineGrainTableModel | getBasicTableModel() | public Class | getColumnClass(int column) | public int | getColumnCount() | public int | getColumnForViewIndex(int viewCol) | public String | getColumnName(int column) | protected Icon | getDescIcon(int column) | public Set<String> | getDifferentColumnValues(int col) can be used for completion... | public Map<String, Integer> | getDifferentColumnValuesStat(int col) | public int | getIndexInFoundFromBasicIndex(int basicIndex) | public int | getIndexInUnsortedFromTablePos(int tablePos) | protected Icon | getNoSortIcon(int column) | public int | getRowCount() | public Vector<Integer> | getSelectedRows_sortedBasicIndices(JTable table) important: this returns a list of indices in the basic model in ascending order
suitable for reverse iterating, for example when removing elements. | public boolean | getSortOrderIsAscending() | public int | getSortedColumn() | public Object | getValueAt(int row, int col) | public int[] | getVisibleColumnsIndex() | public void | installGUI(JTable tHead, JTable table) SPECIAL CASE: Table with row index. | public void | installGUI(JTable _tableReference) used to render headers... | public boolean | isCellEditable(int row, int col) | public boolean | isColumnVisible(int column) | public void | multiSearch(Query[] _queries) | public void | removeOldListeners() | public synchronized void | search(String str1, String str2, boolean useRegEx) | public void | setAllColumnsVisible() | public void | setBasicTableModel(FineGrainTableModel basicTableModel, int sortedColumn, boolean ascending) | public void | setColumnVisibilityToggle(boolean enable) | public void | setColumnVisible(int column, boolean visible) | protected void | setHeaders() set the headers with sort icons. | public void | setPreferredColumnSizesFromModel() | public void | setSortedColumnAndOrder(int col, boolean ascending) | public void | setValueAt(Object val, int row, int col) | public void | setVisibleColumns(int[] cols) | public void | sort(int column, boolean ascending) | public synchronized void | storeTableSelection() | public synchronized void | terminate() free resource, listeners and so on... |
ascending | boolean ascending(Code) | | |
numberOfColumnAsRowHeaders | int numberOfColumnAsRowHeaders(Code) | | |
sortedColumnInBasicModel | int sortedColumnInBasicModel(Code) | | |
tableRowHeadersReference | JTable tableRowHeadersReference(Code) | | |
SortableTableModel | public SortableTableModel(FineGrainTableModel basicTableModel)(Code) | | wraps a sortable feature around your basic table model
Easy usage:
1) just create your model, pass it here
2) use this model as tablemodel for your jtable.
3) After that, call installGUI and pass your JTable as argument.
|
SortableTableModel | public SortableTableModel(FineGrainTableModel basicTableModel, int sortedColumn, boolean ascending)(Code) | | wraps a sortable feature around your basic table model
Easy usage:
1) just create your model, pass it here
2) use this model as tablemodel for your jtable.
3) After that, call installGUI and pass your JTable as argument.
|
advancedSearch | public synchronized void advancedSearch(String str1, String str2, boolean andSearch, boolean useRegEx, int column)(Code) | | |
getAscIcon | protected Icon getAscIcon(int column)(Code) | | returns the ascending/descending sort icons.
this method may be overwritten by subclasses
in order to provide their own icons
|
getColumnClass | public Class getColumnClass(int column)(Code) | | |
getColumnCount | public int getColumnCount()(Code) | | |
getColumnForViewIndex | public int getColumnForViewIndex(int viewCol)(Code) | | if visible columns are {0,1,3}, view=2, return 3
BE CAREFUL: used in getColumName and getColumnClass !
|
getDescIcon | protected Icon getDescIcon(int column)(Code) | | |
getDifferentColumnValues | public Set<String> getDifferentColumnValues(int col)(Code) | | can be used for completion...
|
getDifferentColumnValuesStat | public Map<String, Integer> getDifferentColumnValuesStat(int col)(Code) | | {value, count}
|
getIndexInFoundFromBasicIndex | public int getIndexInFoundFromBasicIndex(int basicIndex)(Code) | | get the view index corresponding to the one in the basicIndex
|
getIndexInUnsortedFromTablePos | public int getIndexInUnsortedFromTablePos(int tablePos)(Code) | | positions in unsorted
|
getNoSortIcon | protected Icon getNoSortIcon(int column)(Code) | | |
getRowCount | public int getRowCount()(Code) | | |
getSelectedRows_sortedBasicIndices | public Vector<Integer> getSelectedRows_sortedBasicIndices(JTable table)(Code) | | important: this returns a list of indices in the basic model in ascending order
suitable for reverse iterating, for example when removing elements.
silently ignore bad positions (-1).
Parameters: table - uses the passed table to fetch the view selected rows. |
getSortOrderIsAscending | public boolean getSortOrderIsAscending()(Code) | | true if the actual sorting order is ascending (default). |
getSortedColumn | public int getSortedColumn()(Code) | | index in the basic tabel model. |
getVisibleColumnsIndex | public int[] getVisibleColumnsIndex()(Code) | | {0,1,3} for example if column 2 is not visible |
installGUI | public void installGUI(JTable tHead, JTable table)(Code) | | SPECIAL CASE: Table with row index.
the two tables have the same selection model.
|
installGUI | public void installGUI(JTable _tableReference)(Code) | | used to render headers...
|
isCellEditable | public boolean isCellEditable(int row, int col)(Code) | | |
isColumnVisible | public boolean isColumnVisible(int column)(Code) | | |
multiSearch | public void multiSearch(Query[] _queries)(Code) | | |
removeOldListeners | public void removeOldListeners()(Code) | | |
search | public synchronized void search(String str1, String str2, boolean useRegEx)(Code) | | true if the search is active.public synchronized boolean isSearchActive(){if(search1.length()>0) return true;if(search2!=null) return true;return false;}/*String search1 = "";String search2 = null;boolean useRegEx = false;Pattern p1 = null;Pattern p2 = null;int searchColumn = -1; // -1 => allboolean andSearch = true; |
setAllColumnsVisible | public void setAllColumnsVisible()(Code) | | Must be called in the edt !
|
setBasicTableModel | public void setBasicTableModel(FineGrainTableModel basicTableModel, int sortedColumn, boolean ascending)(Code) | | |
setColumnVisibilityToggle | public void setColumnVisibilityToggle(boolean enable)(Code) | | |
setColumnVisible | public void setColumnVisible(int column, boolean visible)(Code) | | Parameters: column - in the base model |
setHeaders | protected void setHeaders()(Code) | | set the headers with sort icons.
[Called from EDT]
|
setPreferredColumnSizesFromModel | public void setPreferredColumnSizesFromModel()(Code) | | actually only for tables without header
Must be caled after installGUI !
|
setSortedColumnAndOrder | public void setSortedColumnAndOrder(int col, boolean ascending)(Code) | | |
setValueAt | public void setValueAt(Object val, int row, int col)(Code) | | |
setVisibleColumns | public void setVisibleColumns(int[] cols)(Code) | | |
sort | public void sort(int column, boolean ascending)(Code) | | |
storeTableSelection | public synchronized void storeTableSelection()(Code) | | only call this when you terminate the table,
to keep selection stored in model (if implemented)
|
terminate | public synchronized void terminate()(Code) | | free resource, listeners and so on...
|
|
|