|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
org.jminor.common.model.AbstractFilteredTableModel<R,C>
R
- the type representing the rows in this table modelC
- type type used to identify columns in this table model, Integer for simple indexed identification for examplepublic abstract class AbstractFilteredTableModel<R,C>
A TableModel implentation that supports filtering, searching and sorting.
AbstractFilteredTableModel tableModel = ...; JTable table = new JTable(tableModel, tableModel.getColumnModel(), tableModel.getSelectionModel());
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jminor.common.model.FilteredTableModel |
---|
FilteredTableModel.SortingState |
Field Summary |
---|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
AbstractFilteredTableModel(TableColumnModel columnModel,
List<? extends ColumnSearchModel<C>> columnFilterModels)
Instantiates a new table model. |
Method Summary | |
---|---|
void |
addColumnHiddenListener(ActionListener listener)
|
void |
addColumnShownListener(ActionListener listener)
|
void |
addFilteringListener(ActionListener listener)
|
protected void |
addItems(List<R> items,
boolean atFront)
Adds the given items to this table model |
void |
addRefreshDoneListener(ActionListener listener)
|
void |
addRefreshStartedListener(ActionListener listener)
|
void |
addSelectedIndexListener(ActionListener listener)
|
void |
addSelectedItemIndex(int index)
Selects the item at index |
void |
addSelectedItemIndexes(List<Integer> indexes)
Adds these indexes to the selection |
void |
addSelectionChangedListener(ActionListener listener)
|
void |
addSortingListener(ActionListener listener)
|
void |
addTableDataChangedListener(ActionListener listener)
|
void |
clear()
Clears all data from this refreshable instance |
void |
clearSelection()
Clears the selection |
void |
clearSortingState()
Clears the column sorting states, without reordering the rows |
boolean |
contains(R item,
boolean includeFiltered)
Returns true if this model contains the given item, visible or filtered. |
protected int |
convertColumnIndexToView(int modelColumnIndex)
Maps the index of the column in the table model at modelColumnIndex to the index of the column
in the view. |
protected abstract void |
doRefresh()
Refreshes the data in this table model. |
void |
filterContents()
Filters the table according to the criteria returned by getFilterCriteria() . |
Point |
findNextItemCoordinate(int fromIndex,
boolean forward,
FilterCriteria<Object> criteria)
Returns a Point denoting the row (point.y) and column index (point.x) of the first value to fulfill the given search criteria. |
Point |
findNextItemCoordinate(int fromIndex,
boolean forward,
String searchText)
Returns a Point denoting the row (point.y) and column index (point.x) of the first value to fulfill the given search criteria. |
List<R> |
getAllItems()
|
protected Class |
getColumnClass(C columnIdentifier)
|
int |
getColumnCount()
|
C |
getColumnIdentifer(int modelColumnIndex)
|
TableColumnModel |
getColumnModel()
|
protected Comparable |
getComparable(Object object,
C columnIdentifier)
|
FilterCriteria<R> |
getFilterCriteria()
Returns the filter criteria defined by this model, this method should return a "accept all" criteria instead of null, if no criteria is defined. |
int |
getFilteredItemCount()
|
List<R> |
getFilteredItems()
|
ColumnSearchModel<C> |
getFilterModel(C columnIdentifier)
|
List<TableColumn> |
getHiddenColumns()
|
R |
getItemAt(int index)
Returns the item found at the given index |
StateObserver |
getMultipleSelectionState()
|
int |
getRowCount()
|
protected FilterCriteria<Object> |
getSearchCriteria(String searchText)
|
protected String |
getSearchValueAt(int rowIndex,
C columnIdentifier)
Returns the value to use when searching through the table. |
int |
getSelectedIndex()
|
Collection<Integer> |
getSelectedIndexes()
|
R |
getSelectedItem()
|
List<R> |
getSelectedItems()
|
int |
getSelectionCount()
|
StateObserver |
getSelectionEmptyState()
|
ListSelectionModel |
getSelectionModel()
|
SortingDirective |
getSortingDirective(C columnIdentifier)
|
int |
getSortingPriority(C columnIdentifier)
|
TableColumn |
getTableColumn(C identifier)
Returns the TableColumn with the given identifier |
int |
getVisibleItemCount()
|
List<R> |
getVisibleItems()
|
int |
indexOf(R item)
Returns the index of the given item |
boolean |
isColumnVisible(C columnIdentifier)
|
boolean |
isFiltered(R item)
Returns true if the given item is filtered in this combo box model |
protected boolean |
isFiltering()
|
protected boolean |
isRefreshing()
|
boolean |
isRegularExpressionSearch()
|
boolean |
isSelectionEmpty()
|
protected boolean |
isSorting()
|
boolean |
isVisible(R item)
Returns true if the given item is visible in this combo box model |
void |
moveSelectionDown()
Moves all selected indexes down one index, wraps around |
void |
moveSelectionUp()
Moves all selected indexes up one index, wraps around |
void |
refresh()
Performs a refresh |
void |
removeColumnHiddenListener(ActionListener listener)
|
void |
removeColumnShownListener(ActionListener listener)
|
void |
removeFilteringListener(ActionListener listener)
|
void |
removeItem(R item)
Removes the given item from this table model |
void |
removeItems(Collection<R> items)
Removes the given items from this table model |
void |
removeRefreshDoneListener(ActionListener listener)
|
void |
removeRefreshStartedListener(ActionListener listener)
|
void |
removeSelectedIndexListener(ActionListener listener)
|
void |
removeSelectionChangedListener(ActionListener listener)
|
void |
removeSortingListener(ActionListener listener)
|
void |
removeTableDataChangedListener(ActionListener listener)
|
void |
selectAll()
Selects all visible entities |
void |
setColumnVisible(C columnIdentifier,
boolean visible)
Toggles the visibility of the column representing the given columnIdentifier. |
void |
setFilterCriteria(FilterCriteria<R> filterCriteria)
|
void |
setRegularExpressionSearch(boolean value)
Specifies whether or not to use regular expressions when searching this table model |
void |
setSelectedItem(R item)
Sets the selected item |
void |
setSelectedItemIndex(int index)
Clears the selection and selects the item at index |
void |
setSelectedItemIndexes(List<Integer> indexes)
Selects the given indexes |
void |
setSelectedItems(List<R> items)
Selects the given items |
void |
setSortingDirective(C columnIdentifier,
SortingDirective directive,
boolean addColumnToSort)
|
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, getColumnClass, getColumnName, getValueAt, isCellEditable, removeTableModelListener, setValueAt |
Constructor Detail |
---|
public AbstractFilteredTableModel(TableColumnModel columnModel, List<? extends ColumnSearchModel<C>> columnFilterModels)
columnModel
- the column model to base this table model oncolumnFilterModels
- the column filter modelsMethod Detail |
---|
public final List<R> getVisibleItems()
getVisibleItems
in interface FilteredModel<R>
public final List<R> getFilteredItems()
getFilteredItems
in interface FilteredModel<R>
public final int getVisibleItemCount()
getVisibleItemCount
in interface FilteredModel<R>
public final int getFilteredItemCount()
getFilteredItemCount
in interface FilteredModel<R>
public final int getColumnCount()
getColumnCount
in interface TableModel
public final int getRowCount()
getRowCount
in interface TableModel
public final boolean contains(R item, boolean includeFiltered)
contains
in interface FilteredModel<R>
item
- the itemincludeFiltered
- if true then the filtered items are included
public final boolean isVisible(R item)
isVisible
in interface FilteredModel<R>
item
- the item
public final boolean isFiltered(R item)
isFiltered
in interface FilteredModel<R>
item
- the item
public final Point findNextItemCoordinate(int fromIndex, boolean forward, String searchText)
findNextItemCoordinate
in interface FilteredTableModel<R,C>
fromIndex
- the row index to start searching at, if this is larger than the size of
the table model or less than 0 the search starts from either 0 or rowCount - 1 depending on search direction.forward
- if true then the search is forward, backwards otherwisesearchText
- the text to search by
FilteredTableModel.isRegularExpressionSearch()
,
FilterCriteria.include(Object)
public final Point findNextItemCoordinate(int fromIndex, boolean forward, FilterCriteria<Object> criteria)
findNextItemCoordinate
in interface FilteredTableModel<R,C>
fromIndex
- the row index to start searching at, if this is larger than the size of
the table model or less than 0 the search starts from either 0 or rowCount - 1 depending on search direction.forward
- if true then the search is forward, backwards otherwisecriteria
- the search criteria
FilterCriteria.include(Object)
public final void refresh()
refresh
in interface Refreshable
public final void clear()
clear
in interface Refreshable
public final ListSelectionModel getSelectionModel()
getSelectionModel
in interface FilteredTableModel<R,C>
public final int getSortingPriority(C columnIdentifier)
getSortingPriority
in interface FilteredTableModel<R,C>
columnIdentifier
- the column identifier
public final SortingDirective getSortingDirective(C columnIdentifier)
getSortingDirective
in interface FilteredTableModel<R,C>
columnIdentifier
- the column identifier
public final void setSortingDirective(C columnIdentifier, SortingDirective directive, boolean addColumnToSort)
setSortingDirective
in interface FilteredTableModel<R,C>
columnIdentifier
- the identifier of the column to sort bydirective
- the sorting directiveaddColumnToSort
- if false then the sorting state is cleared, otherwise
this column is added to the sorted column set according to getSortingPriority()
FilteredTableModel.getSortingPriority(Object)
public final void clearSortingState()
clearSortingState
in interface FilteredTableModel<R,C>
public final boolean isRegularExpressionSearch()
isRegularExpressionSearch
in interface FilteredTableModel<R,C>
public final void setRegularExpressionSearch(boolean value)
setRegularExpressionSearch
in interface FilteredTableModel<R,C>
value
- the valuepublic final ColumnSearchModel<C> getFilterModel(C columnIdentifier)
getFilterModel
in interface FilteredTableModel<R,C>
columnIdentifier
- the column identifier
public final void selectAll()
selectAll
in interface FilteredTableModel<R,C>
FilteredTableModel.addSelectionChangedListener(java.awt.event.ActionListener)
public final void clearSelection()
clearSelection
in interface FilteredTableModel<R,C>
FilteredTableModel.addSelectionChangedListener(java.awt.event.ActionListener)
public final Collection<Integer> getSelectedIndexes()
getSelectedIndexes
in interface FilteredTableModel<R,C>
public final void moveSelectionUp()
moveSelectionUp
in interface FilteredTableModel<R,C>
FilteredTableModel.addSelectionChangedListener(java.awt.event.ActionListener)
public final void moveSelectionDown()
moveSelectionDown
in interface FilteredTableModel<R,C>
FilteredTableModel.addSelectionChangedListener(java.awt.event.ActionListener)
public final void setSelectedItemIndex(int index)
index
setSelectedItemIndex
in interface FilteredTableModel<R,C>
index
- the indexpublic final void addSelectedItemIndex(int index)
index
addSelectedItemIndex
in interface FilteredTableModel<R,C>
index
- the indexpublic final void setSelectedItemIndexes(List<Integer> indexes)
setSelectedItemIndexes
in interface FilteredTableModel<R,C>
indexes
- the indexes to selectpublic final List<R> getSelectedItems()
getSelectedItems
in interface FilteredTableModel<R,C>
public final void setSelectedItems(List<R> items)
setSelectedItems
in interface FilteredTableModel<R,C>
items
- the items to selectpublic final R getSelectedItem()
getSelectedItem
in interface FilteredTableModel<R,C>
public final void setSelectedItem(R item)
setSelectedItem
in interface FilteredTableModel<R,C>
item
- the item to selectpublic final void addSelectedItemIndexes(List<Integer> indexes)
addSelectedItemIndexes
in interface FilteredTableModel<R,C>
indexes
- the indexes to add to the selectionpublic final int getSelectedIndex()
getSelectedIndex
in interface FilteredTableModel<R,C>
public final int getSelectionCount()
getSelectionCount
in interface FilteredTableModel<R,C>
public final boolean isSelectionEmpty()
isSelectionEmpty
in interface FilteredTableModel<R,C>
public final R getItemAt(int index)
getItemAt
in interface FilteredTableModel<R,C>
index
- the index
public final int indexOf(R item)
indexOf
in interface FilteredTableModel<R,C>
item
- the item
public final void filterContents()
getFilterCriteria()
.
This method does not interfere with the internal ordering of the visible items.
filterContents
in interface FilteredModel<R>
FilteredModel.getFilterCriteria()
,
FilteredModel.addFilteringListener(java.awt.event.ActionListener)
public final FilterCriteria<R> getFilterCriteria()
getFilterCriteria
in interface FilteredModel<R>
FilterCriteria.AcceptAllCriteria
public final void setFilterCriteria(FilterCriteria<R> filterCriteria)
setFilterCriteria
in interface FilteredModel<R>
filterCriteria
- the FilterCriteria to usepublic final List<R> getAllItems()
getAllItems
in interface FilteredModel<R>
public final void removeItems(Collection<R> items)
removeItems
in interface FilteredTableModel<R,C>
items
- the items to remove from the modelpublic final void removeItem(R item)
removeItem
in interface FilteredTableModel<R,C>
item
- the item to remove from the modelpublic final TableColumnModel getColumnModel()
getColumnModel
in interface FilteredTableModel<R,C>
public final TableColumn getTableColumn(C identifier)
getTableColumn
in interface FilteredTableModel<R,C>
identifier
- the column identifier
public final C getColumnIdentifer(int modelColumnIndex)
getColumnIdentifer
in interface FilteredTableModel<R,C>
modelColumnIndex
- the column model index
public final void setColumnVisible(C columnIdentifier, boolean visible)
setColumnVisible
in interface FilteredTableModel<R,C>
columnIdentifier
- the column identifiervisible
- if true the column is shown, otherwise it is hiddenpublic final boolean isColumnVisible(C columnIdentifier)
isColumnVisible
in interface FilteredTableModel<R,C>
columnIdentifier
- the key for which to query if its column is visible
public final List<TableColumn> getHiddenColumns()
getHiddenColumns
in interface FilteredTableModel<R,C>
public final StateObserver getSelectionEmptyState()
getSelectionEmptyState
in interface FilteredTableModel<R,C>
public final StateObserver getMultipleSelectionState()
getMultipleSelectionState
in interface FilteredTableModel<R,C>
public final void addColumnHiddenListener(ActionListener listener)
addColumnHiddenListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time a column is hiddenpublic final void removeColumnHiddenListener(ActionListener listener)
removeColumnHiddenListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addColumnShownListener(ActionListener listener)
addColumnShownListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time a column is shownpublic final void removeColumnShownListener(ActionListener listener)
removeColumnShownListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addRefreshStartedListener(ActionListener listener)
addRefreshStartedListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time a refresh is about to startpublic final void removeRefreshStartedListener(ActionListener listener)
removeRefreshStartedListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addRefreshDoneListener(ActionListener listener)
addRefreshDoneListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time a refresh has endedpublic final void removeRefreshDoneListener(ActionListener listener)
removeRefreshDoneListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addFilteringListener(ActionListener listener)
addFilteringListener
in interface FilteredModel<R>
listener
- a listener notified each time this model is filteredpublic final void removeFilteringListener(ActionListener listener)
removeFilteringListener
in interface FilteredModel<R>
listener
- the listener to removepublic final void addSortingListener(ActionListener listener)
addSortingListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time the model has been sorted or the sorting state has been clearedpublic final void removeSortingListener(ActionListener listener)
removeSortingListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addSelectedIndexListener(ActionListener listener)
addSelectedIndexListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time the selected index changespublic final void removeSelectedIndexListener(ActionListener listener)
removeSelectedIndexListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addSelectionChangedListener(ActionListener listener)
addSelectionChangedListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time the selection changespublic final void removeSelectionChangedListener(ActionListener listener)
removeSelectionChangedListener
in interface FilteredTableModel<R,C>
listener
- the listener to removepublic final void addTableDataChangedListener(ActionListener listener)
addTableDataChangedListener
in interface FilteredTableModel<R,C>
listener
- a listener to be notified each time the table data changespublic final void removeTableDataChangedListener(ActionListener listener)
removeTableDataChangedListener
in interface FilteredTableModel<R,C>
listener
- the listener to removeprotected abstract void doRefresh()
protected Comparable getComparable(Object object, C columnIdentifier)
object
- the valuecolumnIdentifier
- the column identifier
protected final int convertColumnIndexToView(int modelColumnIndex)
modelColumnIndex
to the index of the column
in the view. Returns the index of the
corresponding column in the view; returns -1 if this column is not
being displayed. If modelColumnIndex
is less than zero,
returns modelColumnIndex
.
modelColumnIndex
- the index of the column in the model
protected final void addItems(List<R> items, boolean atFront)
items
- the items to addatFront
- if true then the items are added at the frontprotected String getSearchValueAt(int rowIndex, C columnIdentifier)
rowIndex
- the row indexcolumnIdentifier
- the column identifier
protected final FilterCriteria<Object> getSearchCriteria(String searchText)
searchText
- the search text
protected Class getColumnClass(C columnIdentifier)
columnIdentifier
- the column identifier
protected final boolean isFiltering()
protected final boolean isSorting()
protected final boolean isRefreshing()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |