| 
JIDE 3.5.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.jidesoft.swing.LabeledTextField
com.jidesoft.grid.QuickFilterField
com.jidesoft.grid.QuickTableFilterField
public class QuickTableFilterField
QuickTableFilterField works along with any TableModel to provide searching feature.
 
 QuickTableFilterField field = new QuickTableFilterField(anyTableModel, new int[]{1, 2, 0,
 5});
 Later on, when you display the table, instead using your original table model, use getDisplayTableModel().
 
 SortableTable table = new SortableTable(field.getDisplayTableModel());
 
 Usually you place QuickTableFilterField somewhere close to the JTable in the user interface. User can
 type in any text in the text field, you will see the JTable automatically display the data that matches with the
 text.
 
 QuickTableFilterField allows you to choose multiple columns to search. By default, it will search for
 all columns. If you click on the icon before the text field, a popup menu will be shown to allow you choose which
 columns to search. It could be All which means it will search for all columns. You can control which columns to be
 listed in the popup menu using setColumnIndices(int[]). The actual texts can be set using setDisplayNames(String[]). You can also set a text as searching text by calling QuickFilterField.setSearchingText(String).
 
 This component has a timer. If user types very fast, it will accumulate them together and generate only one searching
 action. You can listen to property change event of QuickFilterField.PROPERTY_SEARCH_TEXT to detect any text change
 programmatically.
| Nested Class Summary | |
|---|---|
protected  class | 
QuickTableFilterField.FieldTableFilter
This is a filter used by QuickTableFilterField.  | 
| Nested classes/interfaces inherited from class com.jidesoft.grid.QuickFilterField | 
|---|
QuickFilterField.FieldFilter | 
| Nested classes/interfaces inherited from class com.jidesoft.swing.LabeledTextField | 
|---|
LabeledTextField.PopupMenuCustomizer | 
| Nested classes/interfaces inherited from class javax.swing.JPanel | 
|---|
JPanel.AccessibleJPanel | 
| Nested classes/interfaces inherited from class javax.swing.JComponent | 
|---|
JComponent.AccessibleJComponent | 
| Nested classes/interfaces inherited from class java.awt.Container | 
|---|
Container.AccessibleAWTContainer | 
| Nested classes/interfaces inherited from class java.awt.Component | 
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy | 
| Field Summary | |
|---|---|
protected  Set<Integer> | 
_actualSearchingColumnIndices
 | 
protected  JTable | 
_table
 | 
protected  String | 
_text
 | 
static String | 
PROPERTY_SEARCHING_COLUMNS
 | 
| Fields inherited from class com.jidesoft.grid.QuickFilterField | 
|---|
_filter, _searchingText, PROPERTY_CASE_SENSITIVE, PROPERTY_FROM_END, PROPERTY_FROM_START, PROPERTY_REGEX_ENABLED, PROPERTY_SEARCH_TEXT, PROPERTY_WILDCARD_ENABLED | 
| Fields inherited from class com.jidesoft.swing.LabeledTextField | 
|---|
_button, _contextMenuKeyStroke, _customizer, _hintLabel, _hintText, _icon, _label, _labelText, _showHintTextWhenFocused, _textField | 
| Fields inherited from class javax.swing.JComponent | 
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW | 
| Fields inherited from class java.awt.Component | 
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
QuickTableFilterField()
Creates an empty QuickTableFilterField. | 
|
QuickTableFilterField(TableModel tableModel)
Creates a QuickTableFilterField using the specified tableModel. | 
|
QuickTableFilterField(TableModel tableModel,
                      int[] columnIndices)
Creates a QuickTableFilterField using the specified tableModel. | 
|
QuickTableFilterField(TableModel tableModel,
                      int[] columnIndices,
                      String[] displayNames)
Creates a QuickTableFilterField using the specified tableModel. | 
|
| Method Summary | |
|---|---|
protected  void | 
addFilter(IFilterableTableModel filterableTableModel,
          int columnIndex,
          Filter filter)
Adds the filter to the filterable table model at the specified column index.  | 
 void | 
applyFilter()
 | 
 void | 
applyFilter(String text)
Applies the filter.  | 
protected  void | 
changeFilter()
 | 
protected  boolean | 
compare(Object element,
        String searchingText,
        int rowIndex,
        int columnIndex)
Checks if the element matches the searching text.  | 
protected  String | 
convertElementToString(Object element,
                       int rowIndex,
                       int columnIndex)
Converts the element from Object to string.  | 
protected  JidePopupMenu | 
createContextMenu()
Creates the context menu.  | 
protected  FilterableTableModel | 
createDisplayTableModel(TableModel tableModel)
Deprecated. We switched to use createFilterableTableModel which returns IFilterableTableModel. So if you plan to override it, override createFilterableTableModel method instead.  | 
protected  Filter | 
createFilter()
Creates the filter that will be used in QuickFilterField.applyFilter(String) method. | 
protected  IFilterableTableModel | 
createFilterableTableModel(TableModel tableModel)
Creates FilterableTableModel which will be used by QuickTableFilterField to do the filter.  | 
protected  TableColumnChooserDialog | 
createFilterChooserDialog(Window owner,
                          String title,
                          JTable table)
Creates the column chooser dialog.  | 
 int[] | 
getActualSearchingColumnIndices()
Get the actual searching columns index array set based on the customer's selection on UI.  | 
 int[] | 
getColumnIndices()
Gets the column indices.  | 
 String[] | 
getDisplayNames()
Gets the menu item names in an array.  | 
 IFilterableTableModel | 
getDisplayTableModel()
Gets the display table model.  | 
 int | 
getSearchingColumnIndex()
Deprecated. We enable multiple column filter now so this method is deprecated. Please use getSearchingColumnIndices() instead. | 
 int[] | 
getSearchingColumnIndices()
Get the searching columns index array set by setSearchingColumnIndices(int[]) . | 
 JTable | 
getTable()
Gets the table that is using the displayTableModel.  | 
 TableModel | 
getTableModel()
Gets the table model.  | 
protected  boolean | 
isConfigurationChanged()
Get the flag indicating if the configure like case sensitive of the QuickFilterField is changed.  | 
 boolean | 
isObjectConverterManagerEnabled()
Checks if the ObjectConverter will be used to convert element to string so that it can be compared with the searching text.  | 
protected  boolean | 
isSearchingAllColumns()
Get if current text is applied to all columns.  | 
 void | 
propertyChange(PropertyChangeEvent evt)
 | 
protected  void | 
removeFilter(IFilterableTableModel filterableTableModel,
             int columnIndex,
             Filter filter)
Removes the filter from the filterable table model at the specified column index.  | 
 void | 
setColumnIndices(int[] columnIndices)
Sets the column indices to be searched.  | 
protected  void | 
setConfigurationChanged(boolean configureChanged)
Set the flag indicating if the configure like case sensitive of the QuickFilterField is changed.  | 
 void | 
setDisplayNames(String[] displayNames)
Sets the menu item names.  | 
 void | 
setObjectConverterManagerEnabled(boolean objectConverterManagerEnabled)
Sets the flag if the ObjectConveter will be used to convert the element to String. | 
 void | 
setSearchingColumnIndex(int searchingColumnIndex)
Deprecated. We enable multiple column filter now so this method is deprecated. Please use setSearchingColumnIndices(int[]) instead.
             
             In current situation, if you invoke this method, we will make an array with length as 1 then invoke
             setSearchingColumnIndices(int[]). | 
 void | 
setSearchingColumnIndices(int[] searchingColumnIndices)
Set the searching columns index array.  | 
 void | 
setTable(JTable table)
Sets the table that is using the displayTableModel.  | 
 void | 
setTableModel(TableModel tableModel)
Sets the table model used by this component.  | 
protected  boolean | 
shouldColumnBeIncluded(int column)
Checks if the column should be included for the filter when it is applies to ANY_COLUMNS. | 
 void | 
tableChanged(TableModelEvent e)
Process the table structure changed event to update searching column indices.  | 
| Methods inherited from class com.jidesoft.swing.LabeledTextField | 
|---|
calculateContextMenuLocation, createLabel, createTextField, customizePopupMenu, getBaseline, getButton, getContextMenuKeyStroke, getHintText, getIcon, getLabel, getLabelText, getPopupMenuCustomizer, getText, getTextField, initLayout, isShowHintTextWhenFocused, setColumns, setContextMenuKeyStroke, setEnabled, setHintText, setIcon, setLabelText, setPopupMenuCustomizer, setShowHintTextWhenFocused, setText, showContextMenu, updateUI | 
| Methods inherited from class javax.swing.JPanel | 
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected Set<Integer> _actualSearchingColumnIndices
protected String _text
protected transient JTable _table
public static final String PROPERTY_SEARCHING_COLUMNS
| Constructor Detail | 
|---|
public QuickTableFilterField()
QuickTableFilterField. This method is useless since
 QuickTableFilterField has to have a table model in order to work correctly. So we have this method
 in place mainly to make it JavaBean compatible. You must call setTableModel(javax.swing.table.TableModel)
 after you create QuickTableFilterField using this constructor.
public QuickTableFilterField(TableModel tableModel)
QuickTableFilterField using the specified tableModel.
tableModel - the TableModel
public QuickTableFilterField(TableModel tableModel,
                             int[] columnIndices)
QuickTableFilterField using the specified tableModel.
tableModel - the TableModelcolumnIndices - the columns that you want to give user an option in the popup menu to limit the search.
public QuickTableFilterField(TableModel tableModel,
                             int[] columnIndices,
                             String[] displayNames)
QuickTableFilterField using the specified tableModel.
tableModel - the TableModelcolumnIndices - the columns that you want to give user an option in the popup menu to limit the search.displayNames - the text appears on the popup menu.| Method Detail | 
|---|
public int[] getColumnIndices()
setSearchingColumnIndices(int[]), the actual searching column indices would be changed.
 
public void setColumnIndices(int[] columnIndices)
columnIndices - the indices to the columns to be filtered. You need to make sure all values in the index
                      array are within the range. Otherwise, it will throw ArrayIndexOutOfBoundsException. The
                      order of the indices will determine the order of menu items on the popup menu. Null or an
                      empty array will be ignored, meaning all columns in the table will be searched.
IllegalArgumentException - if the length of columnIndices array is different from that of displayNames
                                  array.public String[] getDisplayNames()
public void setDisplayNames(String[] displayNames)
setColumnIndices(int[]) is invoked, those two arrays need have the same length. Each item in the
 displayNames array means the name to be displayed for the model index stored in the same position of columnIndices
 array.
 
 If setColumnIndices(int[]) is NOT invoked, each item in the displayNames array means the name to be
 displayed for the model index which is equal to the item's position in the array.
displayNames - the names used to create menu items. If you don't specify this parameter, it will use column
                     names in tableModel instead. In most cases, it should be fine.protected JidePopupMenu createContextMenu()
QuickFilterFieldJideSwingUtilities.findFirstComponentByName(java.awt.Container, String). The names are "Filter.caseSensitive",
 "Filter.caseInsensitive", "Filter.matchFromStart" and "Filter.matchAnywhere" respectively.
createContextMenu in class QuickFilterFieldpublic void applyFilter()
applyFilter in class QuickFilterFieldpublic void applyFilter(String text)
applyFilter in class QuickFilterFieldtext - the searching text.protected void changeFilter()
protected void removeFilter(IFilterableTableModel filterableTableModel,
                            int columnIndex,
                            Filter filter)
addFilter(IFilterableTableModel, int, com.jidesoft.filter.Filter)
 are the only two methods where the FilterableTableModel will be changed. So if you would like to use the same filter for several different
 FilterableTableModel, you can override both methods to do it.
filterableTableModel - the FilterableTableModel which is the same as getDisplayTableModel().columnIndex - the column index where the filter will be removed.filter - the filter to be removed.
protected void addFilter(IFilterableTableModel filterableTableModel,
                         int columnIndex,
                         Filter filter)
removeFilter(IFilterableTableModel, int, com.jidesoft.filter.Filter)
 are the only two methods where the FilterableTableModel will be changed. So if you would like to use the same filter for several different
 FilterableTableModel, you can override both methods to do it.
filterableTableModel - the FilterableTableModel which is the same as getDisplayTableModel().columnIndex - the column index where the filter will be added.filter - the filter to be added.public void setTableModel(TableModel tableModel)
tableModel - the TableModelpublic void tableChanged(TableModelEvent e)
tableChanged in interface TableModelListenere - the eventprotected IFilterableTableModel createFilterableTableModel(TableModel tableModel)
tableModel - the actual table model.
@Deprecated protected FilterableTableModel createDisplayTableModel(TableModel tableModel)
tableModel - the actual table model.
protected boolean shouldColumnBeIncluded(int column)
ANY_COLUMNS. We will
 check if the column is visible. If visible, we will further check if the column is part of the column indices
 which is set by setColumnIndices.
column - the column index.
ANY_COLUMNS.public TableModel getTableModel()
public IFilterableTableModel getDisplayTableModel()
QuickTableFilterField doesn't modify the table model that you passed
 in but wrap it in IFilterableTableModel. So if you want to display the result after being filtered, you should
 use this method to get the display table model and set it to your table.
public int[] getActualSearchingColumnIndices()
getColumnIndices() and getSearchingColumnIndices(). It is
 actually the field is searching on. All columns within this set will have a check mark before its name on the pop
 down list of the QuickTableFilterField.
 
public int[] getSearchingColumnIndices()
setSearchingColumnIndices(int[]) .
 
 It means which columns the customer wants the field searchs on. Since it's configurable by the customer, it may
 not be the subset of the getColumnIndices().
 
 Set it to null means searching all columns while empty array means searching no column.
public void setSearchingColumnIndices(int[] searchingColumnIndices)
searchingColumnIndices - the searching column indicator arrayprotected boolean isSearchingAllColumns()
@Deprecated public int getSearchingColumnIndex()
getSearchingColumnIndices() instead.
@Deprecated public void setSearchingColumnIndex(int searchingColumnIndex)
setSearchingColumnIndices(int[]) instead.
             
             In current situation, if you invoke this method, we will make an array with length as 1 then invoke
             setSearchingColumnIndices(int[]).
searchingColumnIndex - the searching column indexpublic JTable getTable()
public void propertyChange(PropertyChangeEvent evt)
propertyChange in interface PropertyChangeListenerpublic void setTable(JTable table)
getDisplayTableModel() to get the model and set it to the table.
table - the JTableprotected Filter createFilter()
QuickFilterFieldQuickFilterField.applyFilter(String) method.
 
 By default, we will create a filter like this.
 
 return new AbstractFilter() {
     public boolean isValueFiltered(Object value) {
          return !compare(value, _searchingText);
     }
 };
 
 You can override it to create your filter. For example, you can create an AbstractTableFilter if the
 isValueFiltered implementation needs to know the actual row and column index.
createFilter in class QuickFilterField
protected boolean compare(Object element,
                          String searchingText,
                          int rowIndex,
                          int columnIndex)
setObjectConverterManagerEnabled(boolean) is set to true. Otherwise, QuickFilterField.compare(Object,String) will be
 used instead.
element - the element to be compared.searchingText - the text in the QuickTableFilterField.rowIndex - the row index of the valuecolumnIndex - the column index of the value
protected String convertElementToString(Object element,
                                        int rowIndex,
                                        int columnIndex)
element - the element to be converted to string.rowIndex - the row index of the valuecolumnIndex - the column index of the value
public boolean isObjectConverterManagerEnabled()
public void setObjectConverterManagerEnabled(boolean objectConverterManagerEnabled)
ObjectConveter will be used to convert the element to String. Default is false.
 If true,  convertElementToString method will use ObjectConverterManager to convert the element to
 String if underlying table model is ContextSensitiveTableModel.
objectConverterManagerEnabled - new value for the objectConverterManagerEnabled flag.protected boolean isConfigurationChanged()
QuickFilterFieldQuickFilterField.applyFilter() is invoked.
isConfigurationChanged in class QuickFilterFieldprotected void setConfigurationChanged(boolean configureChanged)
QuickFilterField
setConfigurationChanged in class QuickFilterFieldconfigureChanged - the flag
protected TableColumnChooserDialog createFilterChooserDialog(Window owner,
                                                             String title,
                                                             JTable table)
owner - the owner of the dialogtitle - the title of the dialogtable - the JTable related to the dialog
  | 
JIDE 3.5.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||