JIDE 3.5.15

com.jidesoft.grid
Class QuickTableFilterField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jidesoft.swing.LabeledTextField
                      extended by com.jidesoft.grid.QuickFilterField
                          extended by com.jidesoft.grid.QuickTableFilterField
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, TableModelListener
Direct Known Subclasses:
AutoFilterBox.AutoFilterBoxFilterField, LuceneQuickTableFilterField

public class QuickTableFilterField
extends QuickFilterField
implements TableModelListener, PropertyChangeListener

QuickTableFilterField works along with any TableModel to provide searching feature.

It is very simple to use it.

 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.

See Also:
Serialized Form

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.grid.QuickFilterField
adjustMismatchColor, compare, compare, convertElementToString, createButton, getDefaultFilterIcon, getDefaultResetIcon, getDefaultResetRolloverIcon, getFilter, getFilterIcon, getMismatchColor, getResetIcon, getResetRolloverIcon, getResourceString, getSearchingDelay, getSearchingText, getWildcardSupport, initComponent, installListeners, isCaseSensitive, isFromEnd, isFromStart, isRegexEnabled, isShowMismatchColor, isWildcardEnabled, matches, setCaseSensitive, setDefaultFilterIcon, setDefaultResetIcon, setDefaultResetRolloverIcon, setFilterIcon, setFromEnd, setFromStart, setMismatchColor, setRegexEnabled, setResetIcon, setResetRolloverIcon, setSearchingDelay, setSearchingText, setShowMismatchColor, setWildcardEnabled, setWildcardSupport, uninstallListeners
 
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 javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_actualSearchingColumnIndices

protected Set<Integer> _actualSearchingColumnIndices

_text

protected String _text

_table

protected transient JTable _table

PROPERTY_SEARCHING_COLUMNS

public static final String PROPERTY_SEARCHING_COLUMNS
See Also:
Constant Field Values
Constructor Detail

QuickTableFilterField

public QuickTableFilterField()
Creates an empty 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.


QuickTableFilterField

public QuickTableFilterField(TableModel tableModel)
Creates a QuickTableFilterField using the specified tableModel.

Parameters:
tableModel - the TableModel

QuickTableFilterField

public QuickTableFilterField(TableModel tableModel,
                             int[] columnIndices)
Creates a QuickTableFilterField using the specified tableModel.

Parameters:
tableModel - the TableModel
columnIndices - the columns that you want to give user an option in the popup menu to limit the search.

QuickTableFilterField

public QuickTableFilterField(TableModel tableModel,
                             int[] columnIndices,
                             String[] displayNames)
Creates a QuickTableFilterField using the specified tableModel.

Parameters:
tableModel - the TableModel
columnIndices - 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

getColumnIndices

public int[] getColumnIndices()
Gets the column indices.

It defines the range that the searching works on. By default, the field will search all columns within that range. All columns in that range will appear on the pop down list of the QuickTableFilterField.

After calling setSearchingColumnIndices(int[]), the actual searching column indices would be changed.

Returns:
the column indices.

setColumnIndices

public void setColumnIndices(int[] columnIndices)
Sets the column indices to be searched.

Parameters:
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.
Throws:
IllegalArgumentException - if the length of columnIndices array is different from that of displayNames array.

getDisplayNames

public String[] getDisplayNames()
Gets the menu item names in an array.

Returns:
the array of menu item names.

setDisplayNames

public void setDisplayNames(String[] displayNames)
Sets the menu item names. The name will be used to create menu items on popup menu.

While 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.

Parameters:
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.

createContextMenu

protected JidePopupMenu createContextMenu()
Description copied from class: QuickFilterField
Creates the context menu. By default, it will add four menu items to the context menu. You can always override this class to add more menu items. The menu item can be looked up by name using JideSwingUtilities.findFirstComponentByName(java.awt.Container, String). The names are "Filter.caseSensitive", "Filter.caseInsensitive", "Filter.matchFromStart" and "Filter.matchAnywhere" respectively.

Overrides:
createContextMenu in class QuickFilterField
Returns:
the context menu.

applyFilter

public void applyFilter()
Overrides:
applyFilter in class QuickFilterField

applyFilter

public void applyFilter(String text)
Applies the filter.

Specified by:
applyFilter in class QuickFilterField
Parameters:
text - the searching text.

changeFilter

protected void changeFilter()

removeFilter

protected void removeFilter(IFilterableTableModel filterableTableModel,
                            int columnIndex,
                            Filter filter)
Removes the filter from the filterable table model at the specified column index. This method and 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.

Parameters:
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.

addFilter

protected void addFilter(IFilterableTableModel filterableTableModel,
                         int columnIndex,
                         Filter filter)
Adds the filter to the filterable table model at the specified column index. This method and 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.

Parameters:
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.

setTableModel

public void setTableModel(TableModel tableModel)
Sets the table model used by this component. It could be any table model, not necessarily be a FilterableTableModel.

Parameters:
tableModel - the TableModel

tableChanged

public void tableChanged(TableModelEvent e)
Process the table structure changed event to update searching column indices.

Specified by:
tableChanged in interface TableModelListener
Parameters:
e - the event
Since:
3.2.2

createFilterableTableModel

protected IFilterableTableModel createFilterableTableModel(TableModel tableModel)
Creates FilterableTableModel which will be used by QuickTableFilterField to do the filter.

Parameters:
tableModel - the actual table model.
Returns:
an IFilterableTableModel.

createDisplayTableModel

@Deprecated
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.

Creates FilterableTableModel which will be used by QuickTableFilterField to do the filter.

Parameters:
tableModel - the actual table model.
Returns:
an FilterableTableModel.

shouldColumnBeIncluded

protected boolean shouldColumnBeIncluded(int column)
Checks if the column should be included for the filter when it is applies to 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.

Parameters:
column - the column index.
Returns:
true if the column should be part of the ANY_COLUMNS.

getTableModel

public TableModel getTableModel()
Gets the table model.

Returns:
the table model.

getDisplayTableModel

public IFilterableTableModel getDisplayTableModel()
Gets the display table model. 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.

Returns:
the table model to be displayed.

getActualSearchingColumnIndices

public int[] getActualSearchingColumnIndices()
Get the actual searching columns index array set based on the customer's selection on UI.

It returns the intersection of 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.

Returns:
the searching columns indicator array.

getSearchingColumnIndices

public int[] getSearchingColumnIndices()
Get the searching columns index array set by 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.

Returns:
the searching columns indicator array.

setSearchingColumnIndices

public void setSearchingColumnIndices(int[] searchingColumnIndices)
Set the searching columns index array.

Parameters:
searchingColumnIndices - the searching column indicator array

isSearchingAllColumns

protected boolean isSearchingAllColumns()
Get if current text is applied to all columns.

Returns:
the flag.

getSearchingColumnIndex

@Deprecated
public int getSearchingColumnIndex()
Deprecated. We enable multiple column filter now so this method is deprecated. Please use getSearchingColumnIndices() instead.

Gets the column index to be searched

Returns:
the column index to be searched. -1 means all columns.

setSearchingColumnIndex

@Deprecated
public 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[]).

Sets the column index to be searched. The menu item in popup menu for the corresponding column will be selected.

Parameters:
searchingColumnIndex - the searching column index

getTable

public JTable getTable()
Gets the table that is using the displayTableModel.

Returns:
the table that is using the displayTableModel.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

setTable

public void setTable(JTable table)
Sets the table that is using the displayTableModel. The only reason we want to know the table is to update the column model listener so that when the column model changes, we can filter by the latest columns.

Please note, this method will be set displayTableModel onto the table. You still need to call getDisplayTableModel() to get the model and set it to the table.

Parameters:
table - the JTable

createFilter

protected Filter createFilter()
Description copied from class: QuickFilterField
Creates the filter that will be used in QuickFilterField.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.

Overrides:
createFilter in class QuickFilterField
Returns:
the filter.

compare

protected boolean compare(Object element,
                          String searchingText,
                          int rowIndex,
                          int columnIndex)
Checks if the element matches the searching text. This method is only used when setObjectConverterManagerEnabled(boolean) is set to true. Otherwise, QuickFilterField.compare(Object,String) will be used instead.

Parameters:
element - the element to be compared.
searchingText - the text in the QuickTableFilterField.
rowIndex - the row index of the value
columnIndex - the column index of the value
Returns:
true if matches.

convertElementToString

protected String convertElementToString(Object element,
                                        int rowIndex,
                                        int columnIndex)
Converts the element from Object to string. It will use ObjectConverterManager to do the conversion if the underlying table model is ContextSensitiveTableModel. Otherwise, we will call super convertElementToString method.

You can subclass and override this method to do your own conversion if needed.

Parameters:
element - the element to be converted to string.
rowIndex - the row index of the value
columnIndex - the column index of the value
Returns:
the string representation of the element. "" if the element is null. Otherwise it will call toString to do the conversion.

isObjectConverterManagerEnabled

public boolean isObjectConverterManagerEnabled()
Checks if the ObjectConverter will be used to convert element to string so that it can be compared with the searching text.

Returns:
true or false.

setObjectConverterManagerEnabled

public void setObjectConverterManagerEnabled(boolean objectConverterManagerEnabled)
Sets the flag if the 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.

Parameters:
objectConverterManagerEnabled - new value for the objectConverterManagerEnabled flag.

isConfigurationChanged

protected boolean isConfigurationChanged()
Description copied from class: QuickFilterField
Get the flag indicating if the configure like case sensitive of the QuickFilterField is changed.

This flag will be set to true automatically every time the customer change the settings by UI then switch it back to false right after QuickFilterField.applyFilter() is invoked.

Overrides:
isConfigurationChanged in class QuickFilterField
Returns:
the flag

setConfigurationChanged

protected void setConfigurationChanged(boolean configureChanged)
Description copied from class: QuickFilterField
Set the flag indicating if the configure like case sensitive of the QuickFilterField is changed.

Overrides:
setConfigurationChanged in class QuickFilterField
Parameters:
configureChanged - the flag

createFilterChooserDialog

protected TableColumnChooserDialog createFilterChooserDialog(Window owner,
                                                             String title,
                                                             JTable table)
Creates the column chooser dialog.

Parameters:
owner - the owner of the dialog
title - the title of the dialog
table - the JTable related to the dialog
Returns:
the dialog.
Since:
3.4.5

JIDE 3.5.15