org.jminor.common.model
Interface FilteredTableModel<R,C>

Type Parameters:
R - the type representing the rows in this table model
C - type type used to identify columns in this table model, Integer for simple indexed identification for example
All Superinterfaces:
FilteredModel<R>, Refreshable, TableModel
All Known Subinterfaces:
EntityTableModel
All Known Implementing Classes:
AbstractFilteredTableModel, DefaultEntityTableModel

public interface FilteredTableModel<R,C>
extends FilteredModel<R>, TableModel, Refreshable

Specifies a table model that can be filtered.


Nested Class Summary
static interface FilteredTableModel.SortingState
          Specifies a sorting state for a column.
 
Method Summary
 void addColumnHiddenListener(ActionListener listener)
           
 void addColumnShownListener(ActionListener listener)
           
 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 clearSelection()
          Clears the selection
 void clearSortingState()
          Clears the column sorting states, without reordering the rows
 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.
 C getColumnIdentifer(int modelColumnIndex)
           
 TableColumnModel getColumnModel()
           
 ColumnSearchModel<C> getFilterModel(C columnIdentifier)
           
 Collection<TableColumn> getHiddenColumns()
           
 R getItemAt(int index)
          Returns the item found at the given index
 StateObserver getMultipleSelectionState()
           
 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 indexOf(R item)
          Returns the index of the given item
 boolean isColumnVisible(C columnIdentifier)
           
 boolean isRegularExpressionSearch()
           
 boolean isSelectionEmpty()
           
 void moveSelectionDown()
          Moves all selected indexes down one index, wraps around
 void moveSelectionUp()
          Moves all selected indexes up one index, wraps around
 void removeColumnHiddenListener(ActionListener listener)
           
 void removeColumnShownListener(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 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 interface org.jminor.common.model.FilteredModel
addFilteringListener, contains, filterContents, getAllItems, getFilterCriteria, getFilteredItemCount, getFilteredItems, getVisibleItemCount, getVisibleItems, isFiltered, isVisible, removeFilteringListener, setFilterCriteria
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from interface org.jminor.common.model.Refreshable
clear, refresh
 

Method Detail

getSelectionEmptyState

StateObserver getSelectionEmptyState()
Returns:
a State active when the selection is empty

getMultipleSelectionState

StateObserver getMultipleSelectionState()
Returns:
a State active when multiple rows are selected

addSelectionChangedListener

void addSelectionChangedListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time the selection changes

removeSelectionChangedListener

void removeSelectionChangedListener(ActionListener listener)
Parameters:
listener - the listener to remove

addSelectedIndexListener

void addSelectedIndexListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time the selected index changes

removeSelectedIndexListener

void removeSelectedIndexListener(ActionListener listener)
Parameters:
listener - the listener to remove

addRefreshStartedListener

void addRefreshStartedListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time a refresh is about to start

removeRefreshStartedListener

void removeRefreshStartedListener(ActionListener listener)
Parameters:
listener - the listener to remove

addRefreshDoneListener

void addRefreshDoneListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time a refresh has ended

removeRefreshDoneListener

void removeRefreshDoneListener(ActionListener listener)
Parameters:
listener - the listener to remove

addSortingListener

void addSortingListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time the model has been sorted or the sorting state has been cleared

removeSortingListener

void removeSortingListener(ActionListener listener)
Parameters:
listener - the listener to remove

addColumnHiddenListener

void addColumnHiddenListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time a column is hidden

removeColumnHiddenListener

void removeColumnHiddenListener(ActionListener listener)
Parameters:
listener - the listener to remove

addColumnShownListener

void addColumnShownListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time a column is shown

removeColumnShownListener

void removeColumnShownListener(ActionListener listener)
Parameters:
listener - the listener to remove

addTableDataChangedListener

void addTableDataChangedListener(ActionListener listener)
Parameters:
listener - a listener to be notified each time the table data changes

removeTableDataChangedListener

void removeTableDataChangedListener(ActionListener listener)
Parameters:
listener - the listener to remove

getItemAt

R getItemAt(int index)
Returns the item found at the given index

Parameters:
index - the index
Returns:
the item at the given row index

indexOf

int indexOf(R item)
Returns the index of the given item

Parameters:
item - the item
Returns:
the index of the given item or -1 if it was not found

removeItems

void removeItems(Collection<R> items)
Removes the given items from this table model

Parameters:
items - the items to remove from the model

removeItem

void removeItem(R item)
Removes the given item from this table model

Parameters:
item - the item to remove from the model

getColumnModel

TableColumnModel getColumnModel()
Returns:
the TableColumnModel used by this TableModel

getTableColumn

TableColumn getTableColumn(C identifier)
Returns the TableColumn with the given identifier

Parameters:
identifier - the column identifier
Returns:
the TableColumn with the given identifier, null if none is found

getColumnIdentifer

C getColumnIdentifer(int modelColumnIndex)
Parameters:
modelColumnIndex - the column model index
Returns:
the column identifier

getHiddenColumns

Collection<TableColumn> getHiddenColumns()
Returns:
an unmodifiable view of hidden table columns

isColumnVisible

boolean isColumnVisible(C columnIdentifier)
Parameters:
columnIdentifier - the key for which to query if its column is visible
Returns:
true if the column is visible, false if it is hidden

setColumnVisible

void setColumnVisible(C columnIdentifier,
                      boolean visible)
Toggles the visibility of the column representing the given columnIdentifier.

Parameters:
columnIdentifier - the column identifier
visible - if true the column is shown, otherwise it is hidden

setSortingDirective

void setSortingDirective(C columnIdentifier,
                         SortingDirective directive,
                         boolean addColumnToSort)
Parameters:
columnIdentifier - the identifier of the column to sort by
directive - the sorting directive
addColumnToSort - if false then the sorting state is cleared, otherwise this column is added to the sorted column set according to getSortingPriority()
See Also:
getSortingPriority(Object)

getSortingDirective

SortingDirective getSortingDirective(C columnIdentifier)
Parameters:
columnIdentifier - the column identifier
Returns:
the sorting directive assigned to the given column

getSortingPriority

int getSortingPriority(C columnIdentifier)
Parameters:
columnIdentifier - the column identifier
Returns:
the sorting priority for the given column

findNextItemCoordinate

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.

Parameters:
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 otherwise
searchText - the text to search by
Returns:
the search result coordinate, null if nothing was found
See Also:
isRegularExpressionSearch(), FilterCriteria.include(Object)

findNextItemCoordinate

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.

Parameters:
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 otherwise
criteria - the search criteria
Returns:
the search result coordinate, null if nothing was found
See Also:
FilterCriteria.include(Object)

isRegularExpressionSearch

boolean isRegularExpressionSearch()
Returns:
true if regular expressions should be used when searching this table model

setRegularExpressionSearch

void setRegularExpressionSearch(boolean value)
Specifies whether or not to use regular expressions when searching this table model

Parameters:
value - the value

getFilterModel

ColumnSearchModel<C> getFilterModel(C columnIdentifier)
Parameters:
columnIdentifier - the column identifier
Returns:
the SearchModel at the given column index

isSelectionEmpty

boolean isSelectionEmpty()
Returns:
true if no rows are selected in this table model

getSelectedIndex

int getSelectedIndex()
Returns:
the index of the selected record, -1 if none is selected and the lowest index if more than one record is selected

addSelectedItemIndex

void addSelectedItemIndex(int index)
Selects the item at index

Parameters:
index - the index

setSelectedItemIndex

void setSelectedItemIndex(int index)
Clears the selection and selects the item at index

Parameters:
index - the index

clearSelection

void clearSelection()
Clears the selection

See Also:
addSelectionChangedListener(java.awt.event.ActionListener)

setSelectedItemIndexes

void setSelectedItemIndexes(List<Integer> indexes)
Selects the given indexes

Parameters:
indexes - the indexes to select

setSelectedItems

void setSelectedItems(List<R> items)
Selects the given items

Parameters:
items - the items to select

getSelectedItems

List<R> getSelectedItems()
Returns:
a list containing the selected items

getSelectedItem

R getSelectedItem()
Returns:
the selected item, null if none is selected

getSelectedIndexes

Collection<Integer> getSelectedIndexes()
Returns:
the selected indexes, an empty collection if selection is empty

setSelectedItem

void setSelectedItem(R item)
Sets the selected item

Parameters:
item - the item to select

selectAll

void selectAll()
Selects all visible entities

See Also:
addSelectionChangedListener(java.awt.event.ActionListener)

addSelectedItemIndexes

void addSelectedItemIndexes(List<Integer> indexes)
Adds these indexes to the selection

Parameters:
indexes - the indexes to add to the selection

getSelectionCount

int getSelectionCount()
Returns:
the number of selected indexes in the underlying selection model.

moveSelectionDown

void moveSelectionDown()
Moves all selected indexes down one index, wraps around

See Also:
addSelectionChangedListener(java.awt.event.ActionListener)

moveSelectionUp

void moveSelectionUp()
Moves all selected indexes up one index, wraps around

See Also:
addSelectionChangedListener(java.awt.event.ActionListener)

getSelectionModel

ListSelectionModel getSelectionModel()
Returns:
the selection model used by this table model

clearSortingState

void clearSortingState()
Clears the column sorting states, without reordering the rows