JIDE 3.5.15

com.jidesoft.grid
Class AdvancePageTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.grid.AbstractPageTableModel
          extended by com.jidesoft.grid.AdvancePageTableModel
All Implemented Interfaces:
AutoFilterTableHeaderAdapter, AutoFilterTableModel, ContextSensitiveTableModel, IFilterableTableModel, ISortableTableModel, MultiTableModel, PageNavigationSupport, Serializable, EventListener, TableModelListener, TableModel
Direct Known Subclasses:
HibernatePageTableModel

public abstract class AdvancePageTableModel
extends AbstractPageTableModel
implements ISortableTableModel, IFilterableTableModel

AdvancedPageTableModel extends AbstractPageTableModel and provides more advanced features such as sorting and filtering. However it doesn't implement it by leaving it to the subclass. For example, if you are using Hibernate, you can ask Hibernate to do the filtering or sorting for you. Or if you have a business logic layer in your application, you can handle it in the business logic layer. All other logic is implemented in this class and you only need to implement refreshData(SortItemSupport, FilterItemSupport, int, int) method to provide the content for the current page.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.ISortableTableModel
ISortableTableModel.SortItem
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.IFilterableTableModel
IFilterableTableModel.FilterItem
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.AutoFilterTableHeaderAdapter
AutoFilterTableHeaderAdapter.FilterTitleFormatter
 
Field Summary
protected  FilterItemSupport _filterItemSupport
           
protected  SortItemSupport _sortItemSupport
           
 
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.IFilterableTableModel
ALL_COLUMNS, ANY_COLUMNS, IDENTIFIER_ALL_COLUMNS, IDENTIFIER_ANY_COLUMNS
 
Fields inherited from interface com.jidesoft.grid.MultiTableModel
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN
 
Constructor Summary
  AdvancePageTableModel()
           
protected AdvancePageTableModel(int pageSize)
           
 
Method Summary
 void addFilter(Filter filter)
          Adds a filter to all columns.
 void addFilter(IFilterableTableModel.FilterItem filterItem)
          Adds a FilterItem.
 void addFilter(int column, Filter filter)
          Adds a filter to the specified column.
 void addFilterableTableModelListener(FilterableTableModelListener l)
          Adds a listener to the list that's notified each time a change to the filter occurs.
 void addSortListener(SortListener l)
          Adds the specified listener to receive SortEvents pane events from this SortableTableModel.
 void clearFilters()
          Removes all filters from all columns.
 void fireFilterAdded(int column, Filter filter)
           
 void fireFilterChanged(FilterableTableModelEvent e)
          Forwards the given notification event to all FilterableTableModelListeners that registered themselves as listeners for this table model.
 void fireFilterRemoved(int column, Filter filter)
           
 void fireSortEvent()
          Fires sort event.
 void fireSortingEvent()
          Fires sort event.
 int getActualRowAt(int row)
          Gets the actual row.
 Class<?> getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 int getColumnSortRank(int column)
          In the case of sort by multiple columns, this method will return the rank of this column within all sorted columns.
 TableModel getCurrentPageModel()
           
 DynamicTableFilter[] getDynamicTableFilters(int modelIndex)
          Gets all the DynamicTableFilters.
 FilterableTableModelListener[] getFilterableTableModelListeners()
          Returns an array of all the FilterableTableModel listeners registered on this filter.
 Icon getFilterIcon(int column)
          Gets the filter icon for a particular column.
 List<IFilterableTableModel.FilterItem> getFilterItems()
          Gets all the FilterItems added to this FilterableTableModel.
 Filter[] getFilters(int column)
          Gets the filters for the specified column.
 AutoFilterTableHeaderAdapter.FilterTitleFormatter getFilterTitleFormatter(int column)
          Gets the formatter that will format the title for the AutoFilterTableHeader.
 ListCellRenderer getListCellRenderer(int column)
          Gets the list cell renderer for the drop down filter list.
 int[] getMasterSortColumns()
          Gets the master sort columns.
 int getMaximumSortColumns()
          Gets the maximum columns can be sorted at once.
 Object[] getPossibleValues(int columnIndex, Comparator comparator)
          Gets all possible values of the table model.
 Object[] getPossibleValuesAndConverters(int columnIndex, Comparator comparator)
           
 int getSortedRowAt(int actualRow)
          Gets the visual row.
 List<ISortableTableModel.SortItem> getSortingColumns()
          Gets the sorting columns.
 SortListener[] getSortListeners()
          Returns an array of all the SortListeners added to this SortableTableModel with addSortListener.
 int getSortPriority()
          Gets the sort priority.
 StringConverter getTitleConverter(int column)
          Gets the title converter to convert the column name.
 int getTotalRecordCount()
          Gets the total record/row count.
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean hasFilter()
          Checks if the FilterableTableModel has any filters.
 boolean hasFilter(int columnIndex)
          Checks if the FilterableTableModel has any filters on the specified column.
 boolean isAdjusting()
          Checks if the FilterableTableModel is adjusting.
 boolean isAllowCustomFilter(int column)
          Checks if the AutoFilterTableHeader allows custom filter.
 boolean isAllowMultipleValues(int column)
          Checks if the AutoFilterTableHeader allows multiple values as the filter for the column index.
 boolean isAndMode()
          Sets the logic of filters on the same column.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isColumnAscending(int column)
          Checks if the column is sorted ascendingly.
 boolean isColumnAutoFilterable(int column)
          Checks if the column is auto-filterable.
 boolean isColumnFilterable(int column)
          Checks if the column is filterable for the filters that are added to IFilterableTableModel.ALL_COLUMNS.
 boolean isColumnSortable(int column)
          Check if a certain column is sortable.
 boolean isColumnSorted(int column)
          Checks if the column is sorted.
 boolean isColumnVisible(int column)
          Checks if the column is visible.
 boolean isFilteringPaused()
          Checks if the filtering is paused.
 boolean isFiltersApplied()
          Checks if the filters are in effect.
 boolean isMultiColumnSortable()
          Does this table allow sort by multiple columns.
 boolean isSameConverterAt(int columnIndex)
          Check if each converter in this column for each row is the same.
 boolean isSortable()
          Checks if the sortable table model is sortable.
 boolean isUseTableCellRenderer(int column)
          Checks if the table cell renderer will be used for the list.
 boolean isValuePredetermined(int column)
          Checks if the column is type-filterable.
protected  void pageCountChanged(int oldPageCount, int newPageCount)
           
protected  void pageIndexChanged(int oldPageIndex, int newPageIndex)
           
 void refresh()
          Reapply all filters after they are changed.
abstract  void refreshData(SortItemSupport sortItemSupport, FilterItemSupport filterItemSupport, int currentPage, int pageSize)
          Submits the query.
 void removeAllFilters()
          Removes all filters that are added using IFilterableTableModel.addFilter(Filter).
 void removeAllFilters(int column)
          Removes all filters from the specified column.
 void removeFilter(Filter filter)
          Removes the filter from all columns.
 void removeFilter(IFilterableTableModel.FilterItem filterItem)
          Removes the filter item.
 void removeFilter(int column, Filter filter)
          Removes the filter from the specified column.
 void removeFilterableTableModelListener(FilterableTableModelListener l)
          Removes a listener from the list that's notified each time a change to the filter occurs.
 void removeSortListener(SortListener l)
          Removes the specified SortListener so that it no longer receives SortEvents from this SortableTableModel .
 void reset()
          Resets.
 void resort()
          Resort the table.
 void reverseColumnSortOrder(int column)
          Reverses the sort order of the column.
 void setAdjusting(boolean adjusting)
          Sets the FilterableTableModel to adjusting mode.
 void setAndMode(boolean andMode)
          Sets the logic among the filters.
 void setColumnSortable(int column, boolean sortable)
          Sets a column sortable or not sortable.
 void setCurrentPageModel(TableModel model)
           
 void setFilteringPaused(boolean pause)
          If filtering is paused, keep rows in same relative positions Inserts/Deletes shift rows without re-ordering
 void setFiltersApplied(boolean apply)
          Applies or unapplies the filters.
 void setMasterSortColumns(int[] masterSortColumns)
          Sets the master sort column.
 void setMaximumSortColumns(int maximumSortColumns)
          Set the maximum number of columns that can be sorted at once.
 void setMultiColumnSortable(boolean multiColumnSortable)
          Set the value if this table allows sort by multiple columns.
 void setSortable(boolean sortable)
          Sets the table model sortable.
 void setSortingColumns(List<ISortableTableModel.SortItem> list)
          Sets the soring columns.
 void setSortPriority(int sortPriority)
          Sets the sort priority.
 void setTotalRecordCount(int totalRecordCount)
          Sets the total record/row count.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
protected  void sort()
           
 void sortColumn(int column)
          Sort the column, equals to sortColumn(column, false).
 void sortColumn(int column, boolean reset)
          If reset is true, it will remove all existing sort-by columns and only sorts by column.
 void sortColumn(int column, boolean reset, boolean ascending)
          Sorts a column.
 void toggleSortOrder(int column, boolean extend)
          Toggles the sort order on the specified column.
 void unsortColumn(int column)
          Unsorts the column.
 
Methods inherited from class com.jidesoft.grid.AbstractPageTableModel
addPageNavigationListener, createCompoundTableModelEvent, firePageNavigationEvent, fireTableCellsUpdated, fireTableChanged, firstPage, getCellClassAt, getColumnType, getConverterContextAt, getCurrentPage, getEditorContextAt, getPageCount, getPageNavigationListeners, getPageSize, getRowCount, getTableIndex, lastPage, nextPage, pageSizeChanged, previousPage, removePageNavigationListener, setCurrentPage, setPageCount, setPageSize, tableCellsUpdated, tableChanged, tableDataChanged, tableRowsDeleted, tableRowsInserted, tableRowsUpdated, tableStructureChanged
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, 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 javax.swing.table.TableModel
addTableModelListener, getRowCount, removeTableModelListener
 

Field Detail

_sortItemSupport

protected SortItemSupport _sortItemSupport

_filterItemSupport

protected FilterItemSupport _filterItemSupport
Constructor Detail

AdvancePageTableModel

public AdvancePageTableModel()

AdvancePageTableModel

protected AdvancePageTableModel(int pageSize)
Method Detail

pageCountChanged

protected void pageCountChanged(int oldPageCount,
                                int newPageCount)
Specified by:
pageCountChanged in class AbstractPageTableModel

pageIndexChanged

protected void pageIndexChanged(int oldPageIndex,
                                int newPageIndex)
Specified by:
pageIndexChanged in class AbstractPageTableModel

setTotalRecordCount

public void setTotalRecordCount(int totalRecordCount)
Description copied from interface: PageNavigationSupport
Sets the total record/row count.

Specified by:
setTotalRecordCount in interface PageNavigationSupport
Parameters:
totalRecordCount - the new total row count.

getTotalRecordCount

public int getTotalRecordCount()
Description copied from interface: PageNavigationSupport
Gets the total record/row count.

Specified by:
getTotalRecordCount in interface PageNavigationSupport
Returns:
the total record/row count.

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

getColumnClass

public Class<?> getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getSortedRowAt

public int getSortedRowAt(int actualRow)
Description copied from interface: ISortableTableModel
Gets the visual row.

Specified by:
getSortedRowAt in interface ISortableTableModel
Parameters:
actualRow - the actual row in actual model.
Returns:
the row on UI. -1 if cannot find the row.

getActualRowAt

public int getActualRowAt(int row)
Description copied from interface: ISortableTableModel
Gets the actual row.

Specified by:
getActualRowAt in interface ISortableTableModel
Parameters:
row - the row on the UI.
Returns:
the actual row in the actual model. It will throw IllegalArgumentException if the row is out of range.

sortColumn

public void sortColumn(int column)
Description copied from interface: ISortableTableModel
Sort the column, equals to sortColumn(column, false).

Specified by:
sortColumn in interface ISortableTableModel
Parameters:
column - column to be sorted

sortColumn

public void sortColumn(int column,
                       boolean reset)
Description copied from interface: ISortableTableModel
If reset is true, it will remove all existing sort-by columns and only sorts by column. If reset is false, it will keep existing sort-by columns and add the column as a new sort-by column.

Specified by:
sortColumn in interface ISortableTableModel
Parameters:
column - the column index.
reset - true to reset all existing sorting columns before sorting the new column.

unsortColumn

public void unsortColumn(int column)
Description copied from interface: ISortableTableModel
Unsorts the column.

Specified by:
unsortColumn in interface ISortableTableModel
Parameters:
column - column to be removed from sort-by columns

reverseColumnSortOrder

public void reverseColumnSortOrder(int column)
Description copied from interface: ISortableTableModel
Reverses the sort order of the column. The column must be one of sorted column, or else the method will do nothing

Specified by:
reverseColumnSortOrder in interface ISortableTableModel
Parameters:
column - the column index.

sortColumn

public void sortColumn(int column,
                       boolean reset,
                       boolean ascending)
Description copied from interface: ISortableTableModel
Sorts a column.

Specified by:
sortColumn in interface ISortableTableModel
Parameters:
column - the column index.
reset - true to reset all existing sorting columns before sorting the new column.
ascending - true to sort ascending. False to sort descending.

isColumnSorted

public boolean isColumnSorted(int column)
Description copied from interface: ISortableTableModel
Checks if the column is sorted.

Specified by:
isColumnSorted in interface ISortableTableModel
Parameters:
column - the column index.
Returns:
true if the column is sorted.

isColumnAscending

public boolean isColumnAscending(int column)
Description copied from interface: ISortableTableModel
Checks if the column is sorted ascendingly.

Specified by:
isColumnAscending in interface ISortableTableModel
Parameters:
column - the column index.
Returns:
true if column is ascendingly sorted. If it's not sorted or sorted but descending, it will return false.

reset

public void reset()
Description copied from interface: ISortableTableModel
Resets. No columns will be sorted. Nothing will be done if the model was not sorted.

Specified by:
reset in interface ISortableTableModel

toggleSortOrder

public void toggleSortOrder(int column,
                            boolean extend)
Description copied from interface: ISortableTableModel
Toggles the sort order on the specified column. By default, it will sort the column if not sorted. If sorted ascending, it will change to descending. If descending, it will unsort.

Specified by:
toggleSortOrder in interface ISortableTableModel
Parameters:
column - the column index.
extend - if true, extend the current sort to add more sorted columns.

getSortingColumns

public List<ISortableTableModel.SortItem> getSortingColumns()
Description copied from interface: ISortableTableModel
Gets the sorting columns. It's a ArrayList. The element in the list is SortItem which has the column index and sorting direction.

Specified by:
getSortingColumns in interface ISortableTableModel
Returns:
an ArrayList of sorting columns.

setSortingColumns

public void setSortingColumns(List<ISortableTableModel.SortItem> list)
Description copied from interface: ISortableTableModel
Sets the soring columns. It will do a sort action automatically.

Specified by:
setSortingColumns in interface ISortableTableModel
Parameters:
list - a list of SortItems.

getColumnSortRank

public int getColumnSortRank(int column)
Description copied from interface: ISortableTableModel
In the case of sort by multiple columns, this method will return the rank of this column within all sorted columns.

Specified by:
getColumnSortRank in interface ISortableTableModel
Parameters:
column - the column index.
Returns:
the rank of this column within all sorted columns. -1 is the column is not sorted. 0 means the first rank and so on.

setMasterSortColumns

public void setMasterSortColumns(int[] masterSortColumns)
Description copied from interface: ISortableTableModel
Sets the master sort column. If the master sort columns are set, the row order will only be changed when the master sort columns have the same value. This is used when there are cell spans in certain column and you don't want the sorting to mess up the cell span as those rows will have to stay together.

Specified by:
setMasterSortColumns in interface ISortableTableModel
Parameters:
masterSortColumns - the new master sort columns.

getMasterSortColumns

public int[] getMasterSortColumns()
Description copied from interface: ISortableTableModel
Gets the master sort columns.

Specified by:
getMasterSortColumns in interface ISortableTableModel
Returns:
the master sort columns.

isMultiColumnSortable

public boolean isMultiColumnSortable()
Description copied from interface: ISortableTableModel
Does this table allow sort by multiple columns.

Specified by:
isMultiColumnSortable in interface ISortableTableModel
Returns:
true if this table allows sort by multiple columns

setMultiColumnSortable

public void setMultiColumnSortable(boolean multiColumnSortable)
Description copied from interface: ISortableTableModel
Set the value if this table allows sort by multiple columns.

Specified by:
setMultiColumnSortable in interface ISortableTableModel
Parameters:
multiColumnSortable - pass in true if this you want this table allows sort by multiple columns

isSortable

public boolean isSortable()
Description copied from interface: ISortableTableModel
Checks if the sortable table model is sortable.

Specified by:
isSortable in interface ISortableTableModel
Returns:
true or false.

setSortable

public void setSortable(boolean sortable)
Description copied from interface: ISortableTableModel
Sets the table model sortable. If the model is not sortable, ISortableTableModel.toggleSortOrder(int,boolean) will have no effect.

Specified by:
setSortable in interface ISortableTableModel
Parameters:
sortable - true or false.

resort

public void resort()
Description copied from interface: ISortableTableModel
Resort the table. When autoResort is false, the table will be out of order after data changes. The method will resort the table while keeping the sorting columns.

Specified by:
resort in interface ISortableTableModel

getSortPriority

public int getSortPriority()
Description copied from interface: ISortableTableModel
Gets the sort priority.

Specified by:
getSortPriority in interface ISortableTableModel
Returns:
the sort priority. It could be either ISortableTableModel.SORT_PRIORITY_FILO (the default) or ISortableTableModel.SORT_PRIORITY_FIFO.

setSortPriority

public void setSortPriority(int sortPriority)
Description copied from interface: ISortableTableModel
Sets the sort priority. This property only has effect when multiple columns are sorted. When sort priority is FILO (first-in-last-out), the first sorted column has the smallest sort rank (with a number "1" on its column header). If there are more columns being sorted, their sort tank are getting higher based on the the order when they are sorted. Oppositely, when sort priority is FIFO (first-in-first-out), the first sorted column has the sort rank 1. But the moment a new column is sorted, it will get sort rank 1 and push the previous sorted column's sort rank to 2. And so on. If you view it as a queue, you will see it's either a FILO queue or FIFO queue. That's why we call it FIFO or FILO.

Specified by:
setSortPriority in interface ISortableTableModel
Parameters:
sortPriority - must be one the following value: SORT_PRIORITY_FILO (the default), or SORT_PRIORITY_FIFO

getMaximumSortColumns

public int getMaximumSortColumns()
Description copied from interface: ISortableTableModel
Gets the maximum columns can be sorted at once. If user tries to sort another columns when maximum count is met, depending on the value of ISortableTableModel.getSortPriority(), the behavior is different. If sort priority is FILO, nothing will happen when user tries to sort one column. If FIFO, it will push the column with the largest sort rank out.

Specified by:
getMaximumSortColumns in interface ISortableTableModel
Returns:
the maximum sorted column number.

setMaximumSortColumns

public void setMaximumSortColumns(int maximumSortColumns)
Description copied from interface: ISortableTableModel
Set the maximum number of columns that can be sorted at once.

Specified by:
setMaximumSortColumns in interface ISortableTableModel
Parameters:
maximumSortColumns - the maximum number of columns that can be sorted at once.

addSortListener

public void addSortListener(SortListener l)
Adds the specified listener to receive SortEvents pane events from this SortableTableModel.

Specified by:
addSortListener in interface ISortableTableModel
Parameters:
l - the SortListener

removeSortListener

public void removeSortListener(SortListener l)
Removes the specified SortListener so that it no longer receives SortEvents from this SortableTableModel .

Specified by:
removeSortListener in interface ISortableTableModel
Parameters:
l - the SortableTableModel listener

getSortListeners

public SortListener[] getSortListeners()
Returns an array of all the SortListeners added to this SortableTableModel with addSortListener.

Specified by:
getSortListeners in interface ISortableTableModel
Returns:
all of the SortListeners added or an empty array if no listeners have been added
See Also:
addSortListener(com.jidesoft.grid.SortListener)

fireSortEvent

public void fireSortEvent()
Fires sort event.


fireSortingEvent

public void fireSortingEvent()
Fires sort event.


isColumnSortable

public boolean isColumnSortable(int column)
Check if a certain column is sortable.

Specified by:
isColumnSortable in interface ISortableTableModel
Parameters:
column - the column index.
Returns:
true if this table column is sortable.
See Also:
setColumnSortable(int, boolean)

setColumnSortable

public void setColumnSortable(int column,
                              boolean sortable)
Sets a column sortable or not sortable. Please note, you will have to set it again if the table model structure is changed. By default, all columns are sortable.

Specified by:
setColumnSortable in interface ISortableTableModel
Parameters:
column - the column index.
sortable - true to make the column sortable.

sort

protected void sort()

refresh

public void refresh()
Description copied from interface: IFilterableTableModel
Reapply all filters after they are changed.

Specified by:
refresh in interface IFilterableTableModel

isColumnFilterable

public boolean isColumnFilterable(int column)
Description copied from interface: IFilterableTableModel
Checks if the column is filterable for the filters that are added to IFilterableTableModel.ALL_COLUMNS. The column will be excluded if it returns false (same as IFilterableTableModel.isColumnVisible(int) in this case. There is also AutoFilterTableHeaderAdapter.isColumnAutoFilterable(int) which is used for AutoFilterHeader to control if the filter button is visible.

Specified by:
isColumnFilterable in interface IFilterableTableModel
Parameters:
column - the column index.
Returns:
true if the column can be filtered.

isColumnVisible

public boolean isColumnVisible(int column)
Description copied from interface: IFilterableTableModel
Checks if the column is visible. Since column visible information is on the JTable, FilterableTableModel has no idea whether a column is visible. So we added this protected method to give user a chance to tell FilterableTableModel whether a column is visible. If it is not visible, it will not be considered when filtering.

Specified by:
isColumnVisible in interface IFilterableTableModel
Parameters:
column - the column index.
Returns:
true if the column is visible. Otherwise false.

isColumnAutoFilterable

public boolean isColumnAutoFilterable(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Checks if the column is auto-filterable. Please note, this is used in AutoFilterHeader. If it returns false, we will not show the filter button on the header for that column.

Specified by:
isColumnAutoFilterable in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index.
Returns:
true if the column can be filtered.

isValuePredetermined

public boolean isValuePredetermined(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Checks if the column is type-filterable. Please note, this is used in AutoFilterHeader at multiple line mode. If it returns false, we will not show the filter field on the header for that column.

Specified by:
isValuePredetermined in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index.
Returns:
true if the column can be filtered.

addFilter

public void addFilter(int column,
                      Filter filter)
Description copied from interface: IFilterableTableModel
Adds a filter to the specified column.

Specified by:
addFilter in interface IFilterableTableModel
Parameters:
column - the column index. It could also be two special values - IFilterableTableModel.ALL_COLUMNS or IFilterableTableModel.ANY_COLUMNS. If the value is IFilterableTableModel.ANY_COLUMNS, this method will be the same as IFilterableTableModel.addFilter(Filter).
filter - the filter to be added.

addFilter

public void addFilter(Filter filter)
Description copied from interface: IFilterableTableModel
Adds a filter to all columns. if one of the columns matches the filter, the row will be not be filtered.

You can use AbstractFilter to create new filter. If you need the row index or column index in order to decide if the value should be filtered, you can use AbstractTableFilter and use getRowIndex() and getColumnInde() to find out current row or column index.

Please note, addFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
addFilter in interface IFilterableTableModel
Parameters:
filter - the filter to be added.

addFilter

public void addFilter(IFilterableTableModel.FilterItem filterItem)
Description copied from interface: IFilterableTableModel
Adds a FilterItem.

Specified by:
addFilter in interface IFilterableTableModel
Parameters:
filterItem - the FilterItem

removeFilter

public void removeFilter(int column,
                         Filter filter)
Description copied from interface: IFilterableTableModel
Removes the filter from the specified column. The filter must be added using IFilterableTableModel.addFilter(int, Filter).

Please note, removeFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
removeFilter in interface IFilterableTableModel
Parameters:
column - the column index. It could also be two special values - IFilterableTableModel.ALL_COLUMNS or IFilterableTableModel.ANY_COLUMNS. If the value is IFilterableTableModel.ANY_COLUMNS, this method will be the same as IFilterableTableModel.removeFilter(Filter).
filter - the filter to be removed.

removeFilter

public void removeFilter(Filter filter)
Description copied from interface: IFilterableTableModel
Removes the filter from all columns. The filter must be added using IFilterableTableModel.addFilter(Filter).

Please note, removeFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
removeFilter in interface IFilterableTableModel
Parameters:
filter - the filter to be removed.

removeFilter

public void removeFilter(IFilterableTableModel.FilterItem filterItem)
Description copied from interface: IFilterableTableModel
Removes the filter item.

Please note, removeFilter will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
removeFilter in interface IFilterableTableModel
Parameters:
filterItem - the FilterItem to be removed.

removeAllFilters

public void removeAllFilters(int column)
Description copied from interface: IFilterableTableModel
Removes all filters from the specified column. Those filters are added using IFilterableTableModel.addFilter(int, Filter).

Please note, removeAllFilters will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
removeAllFilters in interface IFilterableTableModel
Parameters:
column - the column index where all filters for that column should be removed.

removeAllFilters

public void removeAllFilters()
Description copied from interface: IFilterableTableModel
Removes all filters that are added using IFilterableTableModel.addFilter(Filter). If you want to remove all filters that either added using IFilterableTableModel.addFilter(int, Filter) or IFilterableTableModel.addFilter(Filter), you should use IFilterableTableModel.clearFilters().

Please note, removeAllFilters will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
removeAllFilters in interface IFilterableTableModel

clearFilters

public void clearFilters()
Description copied from interface: IFilterableTableModel
Removes all filters from all columns.

Please note, clearFilters will not change the FilterableTableModel data right away. You still need to call setFiltersApplied(true) to apply the filter. The reason is to give developers a chance to add/remove multiple filters and only updates the data once at the end.

Specified by:
clearFilters in interface IFilterableTableModel

getFilters

public Filter[] getFilters(int column)
Description copied from interface: IFilterableTableModel
Gets the filters for the specified column.

Specified by:
getFilters in interface IFilterableTableModel
Parameters:
column - the column index.
Returns:
the filters for the specified column.

getFilterItems

public List<IFilterableTableModel.FilterItem> getFilterItems()
Description copied from interface: IFilterableTableModel
Gets all the FilterItems added to this FilterableTableModel.

Specified by:
getFilterItems in interface IFilterableTableModel
Returns:
all the FilterItems added to this FilterableTableModel.

setFiltersApplied

public void setFiltersApplied(boolean apply)
Description copied from interface: IFilterableTableModel
Applies or unapplies the filters. By default, the filters are not applied. So after user adds several filters, this method should be called to make filters taking effect. When new filter is added or existing is removed, this method should be called as well.

Specified by:
setFiltersApplied in interface IFilterableTableModel
Parameters:
apply - true to apply the filters.

isFiltersApplied

public boolean isFiltersApplied()
Description copied from interface: IFilterableTableModel
Checks if the filters are in effect.

Specified by:
isFiltersApplied in interface IFilterableTableModel
Returns:
true if filters are in effect.

hasFilter

public boolean hasFilter()
Description copied from interface: IFilterableTableModel
Checks if the FilterableTableModel has any filters.

Specified by:
hasFilter in interface IFilterableTableModel
Returns:
true if there are any filters. Otherwise false.

hasFilter

public boolean hasFilter(int columnIndex)
Description copied from interface: IFilterableTableModel
Checks if the FilterableTableModel has any filters on the specified column.

Specified by:
hasFilter in interface IFilterableTableModel
Parameters:
columnIndex - the column index to check if there is a filter on it.
Returns:
true if there are any filters on the specified column. Otherwise false.

isAndMode

public boolean isAndMode()
Description copied from interface: IFilterableTableModel
Sets the logic of filters on the same column. If true, filters are in AND mode, meaning if one of the filters return true in isValueFiltered method, the value will be filtered. If false, filters are in OR mode, meaning if one of the filters return false, the value will NOT be filtered.

The mode only has effect on the filters of the same columns which includes each column of the table model as well as the two special column value IFilterableTableModel.ALL_COLUMNS and IFilterableTableModel.ANY_COLUMNS.

Specified by:
isAndMode in interface IFilterableTableModel
Returns:
the AND/OR mode. Default is true which means AND mode.

setAndMode

public void setAndMode(boolean andMode)
Description copied from interface: IFilterableTableModel
Sets the logic among the filters. If AND is true, Please note, this logic mode will apply for all filters, no matter it's for a column or any column or all columns. You won't be able to do complex expression such as AND some filters and OR some other filters using one FitlerableTableModel. In order to do more complex expression, you would need multiple FilterableTableModel, one wraps the other. You make filters in each FilterableTableModel to be OR logic, then the logic among the pipe of FilterableTableModels will always be AND logic.

Specified by:
setAndMode in interface IFilterableTableModel
Parameters:
andMode - true or false.

isAdjusting

public boolean isAdjusting()
Checks if the FilterableTableModel is adjusting. If it is adjusting, FilterableTableModel will not apply filter when the actual list model changes.

Specified by:
isAdjusting in interface IFilterableTableModel
Returns:
true if adjusting. Otherwise false.

setAdjusting

public void setAdjusting(boolean adjusting)
Sets the FilterableTableModel to adjusting mode. If it is adjusting, FilterableTableModel will not apply filter when the actual table model changes. After you set adjusting to false, FilterableListModel will re-apply the filter.

Specified by:
setAdjusting in interface IFilterableTableModel
Parameters:
adjusting - true or false.

getPossibleValues

public Object[] getPossibleValues(int columnIndex,
                                  Comparator comparator)
Description copied from interface: IFilterableTableModel
Gets all possible values of the table model. If there is filter on this column, the possible values are collected from the actual table model. If there is no filter on this column, the possible values are collected from this filterable table model. After we collected all the values, we will use Arrays.sort method to sort the values.

The possible values are used by AutoFilterTableHeader to populate the drop down filter list.

Specified by:
getPossibleValues in interface IFilterableTableModel
Parameters:
columnIndex - the column index.
comparator - the comparator. It is used to sort the values.
Returns:
an array of all possible values of certain column in the table model.

getPossibleValuesAndConverters

public Object[] getPossibleValuesAndConverters(int columnIndex,
                                               Comparator comparator)
Specified by:
getPossibleValuesAndConverters in interface IFilterableTableModel

isSameConverterAt

public boolean isSameConverterAt(int columnIndex)
Description copied from interface: IFilterableTableModel
Check if each converter in this column for each row is the same.

Specified by:
isSameConverterAt in interface IFilterableTableModel
Parameters:
columnIndex - the column index
Returns:
true if all converters are the same in every row. Otherwise false.

setFilteringPaused

public void setFilteringPaused(boolean pause)
Description copied from interface: IFilterableTableModel
If filtering is paused, keep rows in same relative positions Inserts/Deletes shift rows without re-ordering

Specified by:
setFilteringPaused in interface IFilterableTableModel
Parameters:
pause - TRUE = Filtering is Paused; FALSE = Filtering is Active

isFilteringPaused

public boolean isFilteringPaused()
Description copied from interface: IFilterableTableModel
Checks if the filtering is paused.

Specified by:
isFilteringPaused in interface IFilterableTableModel
Returns:
true if paused. Otherwise false.

addFilterableTableModelListener

public void addFilterableTableModelListener(FilterableTableModelListener l)
Adds a listener to the list that's notified each time a change to the filter occurs.

Specified by:
addFilterableTableModelListener in interface IFilterableTableModel
Parameters:
l - the FilterableTableModelListener

removeFilterableTableModelListener

public void removeFilterableTableModelListener(FilterableTableModelListener l)
Removes a listener from the list that's notified each time a change to the filter occurs.

Specified by:
removeFilterableTableModelListener in interface IFilterableTableModel
Parameters:
l - the FilterableTableModelListener

getFilterableTableModelListeners

public FilterableTableModelListener[] getFilterableTableModelListeners()
Returns an array of all the FilterableTableModel listeners registered on this filter.

Specified by:
getFilterableTableModelListeners in interface IFilterableTableModel
Returns:
all of this filter's FilterableTableModelListeners or an empty array if no filter listeners are currently registered
See Also:
addFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener), removeFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener)

fireFilterChanged

public void fireFilterChanged(FilterableTableModelEvent e)
Forwards the given notification event to all FilterableTableModelListeners that registered themselves as listeners for this table model.

Parameters:
e - the event to be forwarded
See Also:
addFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener), FilterableTableModelEvent, EventListenerList

fireFilterAdded

public void fireFilterAdded(int column,
                            Filter filter)

fireFilterRemoved

public void fireFilterRemoved(int column,
                              Filter filter)

getFilterIcon

public Icon getFilterIcon(int column)
Gets the filter icon for a particular column.

Specified by:
getFilterIcon in interface IFilterableTableModel
Parameters:
column - the column index.
Returns:
the icon.

getCurrentPageModel

public TableModel getCurrentPageModel()

setCurrentPageModel

public void setCurrentPageModel(TableModel model)

refreshData

public abstract void refreshData(SortItemSupport sortItemSupport,
                                 FilterItemSupport filterItemSupport,
                                 int currentPage,
                                 int pageSize)
Submits the query. At the end of the methods, you just need to create a table model that represents one page of the whole table model and call setCurrentPageModel(javax.swing.table.TableModel).

Parameters:
sortItemSupport - the information for sort items.
filterItemSupport - the information for filter items.
currentPage - the current page.
pageSize - the page size.

getDynamicTableFilters

public DynamicTableFilter[] getDynamicTableFilters(int modelIndex)
Description copied from interface: AutoFilterTableHeaderAdapter
Gets all the DynamicTableFilters.

DynamicTableFilter allows to add your own customize filter to the drop down filter list. Any DynamicTableFilter will become an entry in the list. If user clicks on that entry, the filter will be used to filter the column. What's special about DynamicTableFilter is it allows to to create a filter on fly. For example, in initializeFilter method of DynamicTableFilter, you can pop up a dialog to allow user to select certain information and you return a filter based on user selection. If returning null, no filter will be added. If not null, the filter you just created will be added to the IFilterableTableModel.

Specified by:
getDynamicTableFilters in interface AutoFilterTableHeaderAdapter
Parameters:
modelIndex - the column in the model to add the DynamicTableFilter
Returns:
an array of DynamicTableFilters.

isAllowMultipleValues

public boolean isAllowMultipleValues(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Checks if the AutoFilterTableHeader allows multiple values as the filter for the column index. The difference will be to use a CheckBoxList or a regular JList as the popup panel when clicking on the filter button.

Specified by:
isAllowMultipleValues in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index.
Returns:
true or false.

getTitleConverter

public StringConverter getTitleConverter(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Gets the title converter to convert the column name. The converter will be used when isShowFilterName() returns true.

Specified by:
getTitleConverter in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index
Returns:
the title converter. null if no converter is needed.

getFilterTitleFormatter

public AutoFilterTableHeaderAdapter.FilterTitleFormatter getFilterTitleFormatter(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Gets the formatter that will format the title for the AutoFilterTableHeader. This formatter will be used, when isShowFilterName() returns true, to format the title including column name and filter names.

Specified by:
getFilterTitleFormatter in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index
Returns:
the title converter. null if no converter is needed.

getListCellRenderer

public ListCellRenderer getListCellRenderer(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Gets the list cell renderer for the drop down filter list.

Specified by:
getListCellRenderer in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column in the model to add the DynamicTableFilter
Returns:
an array of DynamicTableFilters.

isUseTableCellRenderer

public boolean isUseTableCellRenderer(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Checks if the table cell renderer will be used for the list.

Specified by:
isUseTableCellRenderer in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index.
Returns:
true or false.

isAllowCustomFilter

public boolean isAllowCustomFilter(int column)
Description copied from interface: AutoFilterTableHeaderAdapter
Checks if the AutoFilterTableHeader allows custom filter. The difference is there will be a (Custom...) item in the drop down list.when clicking on the filter button. The value is only considered when AutoFilterTableHeader.isAllowMultipleValues() returns false.

Specified by:
isAllowCustomFilter in interface AutoFilterTableHeaderAdapter
Parameters:
column - the column index.
Returns:
true or false.

JIDE 3.5.15