|
JIDE 3.5.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
com.jidesoft.database.DatabaseTableModel
public class DatabaseTableModel
DatabaseTableModel uses an existing database connection and a SQL from statement to query the record
from a database and display them in a table model. The from statement could has one database table or multiple
database tables using join statement. The columns in this table model are decided by an optional SQL select statement
you specified. If you didn't specify, we will use "*" which means all the available fields.
DatabaseTableModel, we would try our best to set appropriate cell renderer by using the information
from the ResultSetMetaData.
The folowing meta data information will be considered in ConverterContext:
boolean isCurrency(int column) throws SQLException; // use default currency converter if isConsiderCurrencyField() returns true
int getScale(int column) throws SQLException; // show the digit number after decimal point
int getPrecision(int column) throws SQLException; // show the integer part no larger than precision
The following meta data information will be considered in validate(int, Object):
int isNullable(int column) throws SQLException; // check it in validateNullable(int, Object)
boolean isSigned(int column) throws SQLException; // check it in validateSigned(int, Object)
int getPrecision(int column) throws SQLException; // check it in validatePrecision(int, Object)
Other:
boolean isReadOnly(int column) throws SQLException; // make it not editable in isCellEditable(int, int)
The following meta data information will not be considered:
int getColumnDisplaySize(int column) throws SQLException; // no way to set preferred width to table from table model
int getColumnCount() throws SQLException;
boolean isAutoIncrement(int column) throws SQLException;
boolean isSearchable(int column) throws SQLException;
String getColumnLabel(int column) throws SQLException;
String getColumnName(int column) throws SQLException;
String getSchemaName(int column) throws SQLException;
String getTableName(int column) throws SQLException;
String getCatalogName(int column) throws SQLException;
int getColumnType(int column) throws SQLException;
String getColumnTypeName(int column) throws SQLException;
String getColumnClassName(int column) throws SQLException;
boolean isWritable(int column) throws SQLException; // it's database access related
boolean isDefinitelyWritable(int column) throws SQLException; // it's database access related
boolean isCaseSensitive(int column) throws SQLException; // searching case sensitive
| 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 Connection |
_connection
|
protected ConverterContext[] |
_converterContexts
converter context for columns which was configured on refreshData(com.jidesoft.grid.SortItemSupport,
com.jidesoft.grid.FilterItemSupport)
After configuration, this field will be used at getConverterContextAt(int, int)
You can either override getConverterContextAt(int, int) or configureConverterContexts() to gain
more control on the cell renderers. |
protected FilterItemSupport |
_filterItemSupport
|
protected String |
_fromStatement
|
protected String |
_preStatement
|
protected ResultSetTableModel |
_resultSetTableModel
|
protected String |
_selectStatement
|
protected SortItemSupport |
_sortItemSupport
|
protected Statement |
_statement
|
| 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 |
| Constructor Summary | |
|---|---|
DatabaseTableModel(Connection connection,
String fromStatement)
Creates a DatabaseTableModel. |
|
DatabaseTableModel(Connection connection,
String selectStatement,
String fromStatement)
Creates a DatabaseTableModel. |
|
DatabaseTableModel(Connection connection,
String selectStatement,
String fromStatement,
boolean updatable)
Creates a DatabaseTableModel. |
|
DatabaseTableModel(Connection connection,
String preStatement,
String selectStatement,
String fromStatement)
Creates a DatabaseTableModel. |
|
DatabaseTableModel(Connection connection,
String preStatement,
String selectStatement,
String fromStatement,
boolean updatable)
Creates a DatabaseTableModel. |
|
| 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. |
protected Statement |
adjustStatement(Statement statement,
String sql)
This method is called before every single sql queries to give subclass a chance to override to create their own statement. |
void |
clearFilters()
Removes all filters from all columns. |
void |
close()
|
void |
commit()
|
protected void |
configureConverterContexts()
Configure converter context for columns by the information contained in meta data. |
protected String |
convertElementToString(Filter filter,
Object value)
Converts the value defined in the filter to String so that it can be used in SQL. |
protected String |
createCountStatement(FilterItemSupport filterItemSupport)
Creates the sql statement to find out the row count in the result set. |
protected String |
createOrderStatement(SortItemSupport sortItemSupport)
Create order statement from sort item support. |
protected String |
createPossibleValuesStatement(int columnIndex)
|
protected Statement |
createReadonlyStatement()
Creates a read-only statement. |
protected ResultSetTableModel |
createResultSetTableModel(ResultSet resultSet,
int rowCount)
|
protected StringBuffer |
createSqlStatement(String preStatement,
String selectStatement,
String fromStatement,
SortItemSupport sortItemSupport,
FilterItemSupport filterItemSupport)
Creates a full SQL statement. |
protected Statement |
createStatement()
Creates a Statement. |
protected String |
createWhereStatement(FilterItemSupport filterItemSupport)
|
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<?> |
getCellClassAt(int rowIndex,
int columnIndex)
Gets the type at cell (row, column). |
Class<?> |
getColumnClass(int columnIndex)
|
int |
getColumnCount()
|
Map<String,String> |
getColumnMapping()
|
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. |
ConverterContext |
getConverterContextAt(int rowIndex,
int columnIndex)
Gets the converter context at cell (row, column). |
DynamicTableFilter[] |
getDynamicTableFilters(int modelIndex)
Gets all the DynamicTableFilters. |
EditorContext |
getEditorContextAt(int rowIndex,
int columnIndex)
Gets the editor context at cell (row, column). |
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 |
getRowCount()
|
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. |
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. |
protected void |
initDatabase()
|
void |
invalidateCache()
|
void |
invalidateCache(int row)
|
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 |
isConsiderCurrencyField()
Get the flag if you want to consider the isCurrency field in metaData. |
boolean |
isFilteringPaused()
Not supported in DatabaseTableModel. |
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 |
isUpdatable()
|
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 StringBuffer |
prepareWhereStatement(IFilterableTableModel.FilterItem filterItem)
Convert the existing filter to where statement string. |
void |
refresh()
Reapply all filters after they are changed. |
void |
refreshData(SortItemSupport sortItemSupport,
FilterItemSupport filterItemSupport)
Resubmit the SQL statement. |
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 |
setColumnMapping(Map<String,String> columnMapping)
Sets the column name mapping. |
void |
setColumnSortable(int column,
boolean sortable)
Sets a column sortable or not sortable. |
void |
setConsiderCurrencyField(boolean considerCurrencyField)
Set the flag if you want to consider the isCurrency field in metaData. |
void |
setFilteringPaused(boolean pause)
Not supported in DatabaseTableModel. |
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 |
setUpdatable(boolean updatable)
|
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. |
boolean |
validate(int columnIndex,
Object value)
The interface for the table to check if the input value satisfy the request from the meta data of the database. |
boolean |
validateNullable(int columnIndex,
Object value)
The interface for the table to check if the input value is null and meta data prohibits null value. |
boolean |
validatePrecision(int columnIndex,
Object value)
The interface for the table to check if the input value exceeds the precision meta data allows. |
boolean |
validateSigned(int columnIndex,
Object value)
The interface for the table to check if the input value is negative and meta data prohibits negative value. |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, 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, removeTableModelListener |
| Field Detail |
|---|
protected ResultSetTableModel _resultSetTableModel
protected Connection _connection
protected Statement _statement
protected String _fromStatement
protected String _selectStatement
protected String _preStatement
protected ConverterContext[] _converterContexts
refreshData(com.jidesoft.grid.SortItemSupport,
com.jidesoft.grid.FilterItemSupport)
After configuration, this field will be used at getConverterContextAt(int, int)
You can either override getConverterContextAt(int, int) or configureConverterContexts() to gain
more control on the cell renderers.
protected SortItemSupport _sortItemSupport
protected FilterItemSupport _filterItemSupport
| Constructor Detail |
|---|
public DatabaseTableModel(Connection connection,
String fromStatement)
throws SQLException
connection - a database connection.fromStatement - a SQL from statement. It could be SQLException - if a database related error happens. It could be because the connection is closed.
public DatabaseTableModel(Connection connection,
String selectStatement,
String fromStatement)
throws SQLException
connection - a database connection.selectStatement - a SQL select statement. If null, we default it to "*". If you use AS statement to change
the column name, make sure you also call setColumnMapping(java.util.Map) to set
the mapping.fromStatement - a SQL from statement. It could be SQLException - if a database related error happens. It could be because the connection is closed.
public DatabaseTableModel(Connection connection,
String preStatement,
String selectStatement,
String fromStatement)
throws SQLException
connection - a database connection.preStatement - a pre-clause. It will appear at the beginning of all sql statements. For example, WITH abc
as ( select dummy from dual ) select * from abc. "WITH abc as ( select dummy from dual )"
will be the pre statement. "abc" will be the from statement.selectStatement - a SQL SELECT statement. Do not include the SELECT word in the statement. Just include
everything after the SELECT. If null, we default it to "*". If you use AS statement to
change the column name, make sure you also call setColumnMapping(java.util.Map)
to set the mapping.fromStatement - a SQL FROM clause. Do not include the FROM word in the statement. Just include everything
after the FROM. It could be SQLException - if a database related error happens. It could be because the connection is closed.
public DatabaseTableModel(Connection connection,
String selectStatement,
String fromStatement,
boolean updatable)
throws SQLException
connection - a database connection.selectStatement - a SQL SELECT statement. Do not include the SELECT word in the statement. Just include
everything after the SELECT. If null, we default it to "*". If you use AS statement to
change the column name, make sure you also call setColumnMapping(java.util.Map)
to set the mapping.fromStatement - a SQL FROM clause. Do not include the FROM word in the statement. Just include everything
after the FROM. It could be updatable - if the table model is updatable (or editable)
SQLException - if a database related error happens. It could be because the connection is closed.
public DatabaseTableModel(Connection connection,
String preStatement,
String selectStatement,
String fromStatement,
boolean updatable)
throws SQLException
connection - a database connection.preStatement - a pre-clause. It will appear at the beginning of all sql statements. For example, WITH abc
as ( select dummy from dual ) select * from abc. "WITH abc as ( select dummy from dual )"
will be the pre statement. "abc" will be the from statement.selectStatement - a SQL SELECT statement. Do not include the SELECT word in the statement. Just include
everything after the SELECT. If null, we default it to "*". If you use AS statement to
change the column name, make sure you also call setColumnMapping(java.util.Map)
to set the mapping.fromStatement - a SQL FROM clause. Do not include the FROM word in the statement. Just include everything
after the FROM. It could be updatable - if the table model is updatable (or editable)
SQLException - if a database related error happens. It could be because the connection is closed.| Method Detail |
|---|
protected void initDatabase()
throws SQLException
SQLExceptionpublic void setColumnMapping(Map<String,String> columnMapping)
Map mapping = new HashMap();
mapping.put("CATEGORYNAME", "CATEGORY");
mapping.put("PRODUCTNAME", "PRODUCT");
mapping.put("ORDERDATE", "DATE");
Please note it has to be all upper cases.
columnMapping - the column name mapping.public Map<String,String> getColumnMapping()
public int getColumnCount()
getColumnCount in interface TableModelpublic String getColumnName(int column)
getColumnName in interface TableModelgetColumnName in class AbstractTableModel
public ConverterContext getConverterContextAt(int rowIndex,
int columnIndex)
ContextSensitiveTableModel
getConverterContextAt in interface ContextSensitiveTableModelrowIndex - the row indexcolumnIndex - the column index
public EditorContext getEditorContextAt(int rowIndex,
int columnIndex)
ContextSensitiveTableModel
getEditorContextAt in interface ContextSensitiveTableModelrowIndex - the row indexcolumnIndex - the column index
public Class<?> getCellClassAt(int rowIndex,
int columnIndex)
ContextSensitiveTableModel
getCellClassAt in interface ContextSensitiveTableModelrowIndex - the row indexcolumnIndex - the column index
public Class<?> getColumnClass(int columnIndex)
getColumnClass in interface TableModelgetColumnClass in class AbstractTableModelpublic int getRowCount()
getRowCount in interface TableModel
public Object getValueAt(int rowIndex,
int columnIndex)
getValueAt in interface TableModelpublic int getSortedRowAt(int actualRow)
ISortableTableModel
getSortedRowAt in interface ISortableTableModelactualRow - the actual row in actual model.
public int getActualRowAt(int row)
ISortableTableModel
getActualRowAt in interface ISortableTableModelrow - the row on the UI.
public void sortColumn(int column)
ISortableTableModel
sortColumn in interface ISortableTableModelcolumn - column to be sorted
public void sortColumn(int column,
boolean reset)
ISortableTableModelcolumn. If reset is
false, it will keep existing sort-by columns and add the column as a new sort-by column.
sortColumn in interface ISortableTableModelcolumn - the column index.reset - true to reset all existing sorting columns before sorting the new column.public void unsortColumn(int column)
ISortableTableModel
unsortColumn in interface ISortableTableModelcolumn - column to be removed from sort-by columnspublic void reverseColumnSortOrder(int column)
ISortableTableModel
reverseColumnSortOrder in interface ISortableTableModelcolumn - the column index.
public void sortColumn(int column,
boolean reset,
boolean ascending)
ISortableTableModel
sortColumn in interface ISortableTableModelcolumn - 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.public boolean isColumnSorted(int column)
ISortableTableModel
isColumnSorted in interface ISortableTableModelcolumn - the column index.
public boolean isColumnAscending(int column)
ISortableTableModel
isColumnAscending in interface ISortableTableModelcolumn - the column index.
public void reset()
ISortableTableModel
reset in interface ISortableTableModel
public void toggleSortOrder(int column,
boolean extend)
ISortableTableModel
toggleSortOrder in interface ISortableTableModelcolumn - the column index.extend - if true, extend the current sort to add more sorted columns.public List<ISortableTableModel.SortItem> getSortingColumns()
ISortableTableModel
getSortingColumns in interface ISortableTableModelpublic void setSortingColumns(List<ISortableTableModel.SortItem> list)
ISortableTableModel
setSortingColumns in interface ISortableTableModellist - a list of SortItems.public int getColumnSortRank(int column)
ISortableTableModel
getColumnSortRank in interface ISortableTableModelcolumn - the column index.
public void setMasterSortColumns(int[] masterSortColumns)
ISortableTableModel
setMasterSortColumns in interface ISortableTableModelmasterSortColumns - the new master sort columns.public int[] getMasterSortColumns()
ISortableTableModel
getMasterSortColumns in interface ISortableTableModelpublic boolean isMultiColumnSortable()
ISortableTableModel
isMultiColumnSortable in interface ISortableTableModelpublic void setMultiColumnSortable(boolean multiColumnSortable)
ISortableTableModel
setMultiColumnSortable in interface ISortableTableModelmultiColumnSortable - pass in true if this you want this table allows sort by multiple columnspublic boolean isSortable()
ISortableTableModel
isSortable in interface ISortableTableModelpublic void setSortable(boolean sortable)
ISortableTableModelISortableTableModel.toggleSortOrder(int,boolean) will have no
effect.
setSortable in interface ISortableTableModelsortable - true or false.public void resort()
ISortableTableModel
resort in interface ISortableTableModelpublic int getSortPriority()
ISortableTableModel
getSortPriority in interface ISortableTableModelISortableTableModel.SORT_PRIORITY_FILO (the default) or
ISortableTableModel.SORT_PRIORITY_FIFO.public void setSortPriority(int sortPriority)
ISortableTableModel
setSortPriority in interface ISortableTableModelsortPriority - must be one the following value: SORT_PRIORITY_FILO (the default), or SORT_PRIORITY_FIFOpublic int getMaximumSortColumns()
ISortableTableModelISortableTableModel.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.
getMaximumSortColumns in interface ISortableTableModelpublic void setMaximumSortColumns(int maximumSortColumns)
ISortableTableModel
setMaximumSortColumns in interface ISortableTableModelmaximumSortColumns - the maximum number of columns that can be sorted at once.public void addSortListener(SortListener l)
addSortListener in interface ISortableTableModell - the SortListenerpublic void removeSortListener(SortListener l)
removeSortListener in interface ISortableTableModell - the SortableTableModel listenerpublic SortListener[] getSortListeners()
SortListeners added to this SortableTableModel with
addSortListener.
getSortListeners in interface ISortableTableModelSortListeners added or an empty array if no listeners have been addedaddSortListener(com.jidesoft.grid.SortListener)public void fireSortEvent()
public void fireSortingEvent()
public boolean isColumnSortable(int column)
isColumnSortable in interface ISortableTableModelcolumn - the column index.
setColumnSortable(int, boolean)
public void setColumnSortable(int column,
boolean sortable)
setColumnSortable in interface ISortableTableModelcolumn - the column index.sortable - true to make the column sortable.protected void sort()
protected String createOrderStatement(SortItemSupport sortItemSupport)
sortItemSupport - the sorting information stored in sortItemSupport
protected StringBuffer prepareWhereStatement(IFilterableTableModel.FilterItem filterItem)
OrFilter AndFilter NotFilter LikeFilter EqualFilter
BetweenFilter InFilter SingleValueFilter MultipleValuesFilter
filterItem - the filter item to convert
protected String convertElementToString(Filter filter,
Object value)
filter - the filter where the value is from.value - the value
public void refresh()
IFilterableTableModel
refresh in interface IFilterableTableModelprotected String createWhereStatement(FilterItemSupport filterItemSupport)
public boolean isColumnFilterable(int column)
IFilterableTableModelIFilterableTableModel.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.
isColumnFilterable in interface IFilterableTableModelcolumn - the column index.
public boolean isColumnVisible(int column)
IFilterableTableModel
isColumnVisible in interface IFilterableTableModelcolumn - the column index.
public boolean isColumnAutoFilterable(int column)
AutoFilterTableHeaderAdapterAutoFilterHeader. If it
returns false, we will not show the filter button on the header for that column.
isColumnAutoFilterable in interface AutoFilterTableHeaderAdaptercolumn - the column index.
public boolean isValuePredetermined(int column)
AutoFilterTableHeaderAdapterAutoFilterHeader at multiple
line mode. If it returns false, we will not show the filter field on the header for that column.
isValuePredetermined in interface AutoFilterTableHeaderAdaptercolumn - the column index.
public void addFilter(int column,
Filter filter)
IFilterableTableModel
addFilter in interface IFilterableTableModelcolumn - 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.public void addFilter(Filter filter)
IFilterableTableModelYou
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.
addFilter in interface IFilterableTableModelfilter - the filter to be added.public void addFilter(IFilterableTableModel.FilterItem filterItem)
IFilterableTableModel
addFilter in interface IFilterableTableModelfilterItem - the FilterItem
public void removeFilter(int column,
Filter filter)
IFilterableTableModelIFilterableTableModel.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.
removeFilter in interface IFilterableTableModelcolumn - 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.public void removeFilter(Filter filter)
IFilterableTableModelIFilterableTableModel.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.
removeFilter in interface IFilterableTableModelfilter - the filter to be removed.public void removeFilter(IFilterableTableModel.FilterItem filterItem)
IFilterableTableModel
removeFilter in interface IFilterableTableModelfilterItem - the FilterItem to be removed.public void removeAllFilters(int column)
IFilterableTableModelIFilterableTableModel.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.
removeAllFilters in interface IFilterableTableModelcolumn - the column index where all filters for that column should be removed.public void removeAllFilters()
IFilterableTableModelIFilterableTableModel.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.
removeAllFilters in interface IFilterableTableModelpublic void clearFilters()
IFilterableTableModel
clearFilters in interface IFilterableTableModelpublic Filter[] getFilters(int column)
IFilterableTableModel
getFilters in interface IFilterableTableModelcolumn - the column index.
public List<IFilterableTableModel.FilterItem> getFilterItems()
IFilterableTableModel
getFilterItems in interface IFilterableTableModelpublic void setFiltersApplied(boolean apply)
IFilterableTableModel
setFiltersApplied in interface IFilterableTableModelapply - true to apply the filters.public boolean isFiltersApplied()
IFilterableTableModel
isFiltersApplied in interface IFilterableTableModelpublic boolean hasFilter()
IFilterableTableModelFilterableTableModel has any filters.
hasFilter in interface IFilterableTableModelpublic boolean hasFilter(int columnIndex)
IFilterableTableModelFilterableTableModel has any filters on the specified column.
hasFilter in interface IFilterableTableModelcolumnIndex - the column index to check if there is a filter on it.
public boolean isAndMode()
IFilterableTableModelIFilterableTableModel.ALL_COLUMNS and IFilterableTableModel.ANY_COLUMNS.
isAndMode in interface IFilterableTableModelpublic void setAndMode(boolean andMode)
IFilterableTableModelFitlerableTableModel. 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.
setAndMode in interface IFilterableTableModelandMode - true or false.public boolean isAdjusting()
isAdjusting in interface IFilterableTableModelpublic void setAdjusting(boolean adjusting)
setAdjusting in interface IFilterableTableModeladjusting - true or false.
public Object[] getPossibleValues(int columnIndex,
Comparator comparator)
IFilterableTableModelAutoFilterTableHeader to populate the drop down filter list.
getPossibleValues in interface IFilterableTableModelcolumnIndex - the column index.comparator - the comparator. It is used to sort the values.
public Object[] getPossibleValuesAndConverters(int columnIndex,
Comparator comparator)
getPossibleValuesAndConverters in interface IFilterableTableModelpublic boolean isSameConverterAt(int columnIndex)
IFilterableTableModel
isSameConverterAt in interface IFilterableTableModelcolumnIndex - the column index
protected String createPossibleValuesStatement(int columnIndex)
public void setFilteringPaused(boolean pause)
setFilteringPaused in interface IFilterableTableModelpause - not used.public boolean isFilteringPaused()
isFilteringPaused in interface IFilterableTableModelpublic void addFilterableTableModelListener(FilterableTableModelListener l)
addFilterableTableModelListener in interface IFilterableTableModell - the FilterableTableModelListenerpublic void removeFilterableTableModelListener(FilterableTableModelListener l)
removeFilterableTableModelListener in interface IFilterableTableModell - the FilterableTableModelListenerpublic FilterableTableModelListener[] getFilterableTableModelListeners()
getFilterableTableModelListeners in interface IFilterableTableModelFilterableTableModelListeners or an empty array if no filter listeners
are currently registeredaddFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener),
removeFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener)public void fireFilterChanged(FilterableTableModelEvent e)
FilterableTableModelListeners that registered
themselves as listeners for this table model.
e - the event to be forwardedaddFilterableTableModelListener(com.jidesoft.grid.FilterableTableModelListener),
FilterableTableModelEvent,
EventListenerList
public void fireFilterAdded(int column,
Filter filter)
public void fireFilterRemoved(int column,
Filter filter)
public Icon getFilterIcon(int column)
getFilterIcon in interface IFilterableTableModelcolumn - the column index.
protected Statement createStatement()
throws SQLException
SQLException - if it fails to create a ResultSet.TYPE_FORWARD_ONLY statement after failed to create the
other two types.
protected Statement createReadonlyStatement()
throws SQLException
SQLException - if it fails to create a ResultSet.TYPE_FORWARD_ONLY statement after failed to create the
ResultSet.TYPE_SCROLL_INSENSITIVE statement.
protected Statement adjustStatement(Statement statement,
String sql)
throws SQLException
statement - the default Statement.sql - the sql statement to be executed.
SQLException - when failed to create a statement.
public void refreshData(SortItemSupport sortItemSupport,
FilterItemSupport filterItemSupport)
throws SQLException
refresh(), this method will throw SQLException. If you would like to handle those
exception, you would better invoke this method.
sortItemSupport - the information for sort items.filterItemSupport - the information for filter items.
SQLException - if a database access error occurs, this method is called on a closed Statement
or the given SQL statement produces anything other than a single ResultSet
object
protected ResultSetTableModel createResultSetTableModel(ResultSet resultSet,
int rowCount)
throws SQLException
SQLException
protected void configureConverterContexts()
throws SQLException
_converterContexts will be configured here. You can override this method if you need more precise
control over the cell renderer.
SQLException - if it encounters any database access issue.protected String createCountStatement(FilterItemSupport filterItemSupport)
filterItemSupport - the filterItemSupport which contains the filter information.
protected StringBuffer createSqlStatement(String preStatement,
String selectStatement,
String fromStatement,
SortItemSupport sortItemSupport,
FilterItemSupport filterItemSupport)
preStatement - a pre-clause. It will appear at the beginning of all sql statements. For example, WITH
abc as ( select dummy from dual ) select * from abc. "WITH abc as ( select dummy from
dual )" will be the pre statement. "abc" will be the from statement.selectStatement - a SQL SELECT statement. Do not include the SELECT word in the statement. Just include
everything after the SELECT. If null, we default it to "*". If you use AS statement to
change the column name, make sure you also call setColumnMapping(java.util.Map)
to set the mapping.fromStatement - a SQL FROM clause. Do not include the FROM word in the statement. Just include
everything after the FROM. It could be sortItemSupport - the SortItemSupport which contains the column sorting information.filterItemSupport - the FilterItemSupport which contains the filtering information.
public void setValueAt(Object aValue,
int rowIndex,
int columnIndex)
setValueAt in interface TableModelsetValueAt in class AbstractTableModelpublic void invalidateCache(int row)
public void invalidateCache()
public boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface TableModelisCellEditable in class AbstractTableModelpublic void setUpdatable(boolean updatable)
public boolean isUpdatable()
public void commit()
throws SQLException
SQLException
public void close()
throws SQLException
SQLException
public boolean validate(int columnIndex,
Object value)
public boolean nullCheck(int columnIndex, Object value) throws SQLException;
public boolean signCheck(int columnIndex, Object value) throws SQLException;
public boolean precisionCheck(int columnIndex, Object value) throws SQLException;
columnIndex - the column index to be check invalue - the value to be check
public boolean validateNullable(int columnIndex,
Object value)
throws SQLException
columnIndex - the column index to be check invalue - the value to be check
SQLException - if it encounters database access issue.
public boolean validateSigned(int columnIndex,
Object value)
throws SQLException
columnIndex - the column index to be check invalue - the value to be check
SQLException - if it encounters database access issue.
public boolean validatePrecision(int columnIndex,
Object value)
throws SQLException
columnIndex - the column index to be check invalue - the value to be check
SQLException - if it encounters database access issue.public boolean isConsiderCurrencyField()
setConsiderCurrencyField(boolean) to switch it to true if you
make sure that the database supports this field.
public void setConsiderCurrencyField(boolean considerCurrencyField)
considerCurrencyField - the flag if you want to consider isCurrency field in metaDatapublic DynamicTableFilter[] getDynamicTableFilters(int modelIndex)
AutoFilterTableHeaderAdapterDynamicTableFilters.
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.
getDynamicTableFilters in interface AutoFilterTableHeaderAdaptermodelIndex - the column in the model to add the DynamicTableFilter
DynamicTableFilters.public boolean isAllowMultipleValues(int column)
AutoFilterTableHeaderAdapterAutoFilterTableHeader 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.
isAllowMultipleValues in interface AutoFilterTableHeaderAdaptercolumn - the column index.
public StringConverter getTitleConverter(int column)
AutoFilterTableHeaderAdapter
getTitleConverter in interface AutoFilterTableHeaderAdaptercolumn - the column index
public AutoFilterTableHeaderAdapter.FilterTitleFormatter getFilterTitleFormatter(int column)
AutoFilterTableHeaderAdapter
getFilterTitleFormatter in interface AutoFilterTableHeaderAdaptercolumn - the column index
public ListCellRenderer getListCellRenderer(int column)
AutoFilterTableHeaderAdapter
getListCellRenderer in interface AutoFilterTableHeaderAdaptercolumn - the column in the model to add the DynamicTableFilter
DynamicTableFilters.public boolean isUseTableCellRenderer(int column)
AutoFilterTableHeaderAdapter
isUseTableCellRenderer in interface AutoFilterTableHeaderAdaptercolumn - the column index.
public boolean isAllowCustomFilter(int column)
AutoFilterTableHeaderAdapterAutoFilterTableHeader 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.
isAllowCustomFilter in interface AutoFilterTableHeaderAdaptercolumn - the column index.
|
JIDE 3.5.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||