JIDE 3.5.15

com.jidesoft.lucene
Class LuceneQuickTableFilterField

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
                              extended by com.jidesoft.lucene.LuceneQuickTableFilterField
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, TableModelListener

public class LuceneQuickTableFilterField
extends QuickTableFilterField

LuceneQuickTableFilterField works along with any TableModel except TreeTableModel to provide Lucene-equipped searching feature.

It is very simple to use it.

 LuceneQuickTableFilterField field = new LuceneQuickTableFilterField(anyTableModel, new int[]{1, 2, 0,
 5});
Later on, when you display the table, instead using your original table model, use QuickTableFilterField.getDisplayTableModel().
 SortableTable table = new SortableTable(field.getDisplayTableModel());
 
Usually you place LuceneQuickTableFilterField 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.

LuceneQuickTableFilterField has two input mode.

One is normal input mode just like QuickTableFilterField, which 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 QuickTableFilterField.setColumnIndices(int[]). The actual texts can be set using QuickTableFilterField.setDisplayNames(String[]). You can also set a text as searching text by calling QuickFilterField.setSearchingText(String). In this mode, we will parse the input text for you to accommodate Lucene syntax. Since we still have to parse the input text, so some options valid in QuickTableFilterField like case sensitive/insensitive, wildcard flag will not valid any more.

Another is Lucene input mode. In this mode, we will just pass your input text directly to lucene QueryParser, so you have to know exactly what Lucene syntax allows and not allows. We provided available input in the popup menu based on Lucene 2.4.1, so you can get limited help from the menu. We also provided an link to Lucene help documents. You can invoke LuceneFilterMenuSupport.setLuceneHelpURL(String) to change the link if you have better reference.

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
 
Nested classes/interfaces inherited from class com.jidesoft.grid.QuickTableFilterField
QuickTableFilterField.FieldTableFilter
 
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
 
Fields inherited from class com.jidesoft.grid.QuickTableFilterField
_actualSearchingColumnIndices, _table, _text, 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
LuceneQuickTableFilterField()
          Creates an empty LuceneQuickTableFilterField.
LuceneQuickTableFilterField(TableModel tableModel)
          Creates a LuceneQuickTableFilterField using the specified tableModel.
LuceneQuickTableFilterField(TableModel tableModel, int[] columnIndices)
          Creates a LuceneQuickTableFilterField using the specified tableModel.
LuceneQuickTableFilterField(TableModel tableModel, int[] columnIndices, String[] displayNames)
          Creates a LuceneQuickTableFilterField using the specified tableModel.
 
Method Summary
 void applyFilter(String text)
          Applies the filter.
protected  JidePopupMenu createContextMenu()
          Creates the context menu.
protected  IFilterableTableModel createFilterableTableModel(TableModel tableModel)
          Creates LuceneFilterableTableModel which will be used by LuceneQuickTableFilterField to do the filter.
 com.jidesoft.lucene.LuceneDocumentProvider getLuceneDocumentProvider()
           
static String getLuceneHelpURL()
          Deprecated. please use LuceneFilterMenuSupport.getLuceneHelpURL() instead
 String getResourceString(String key)
           
 JTextField getTextField()
           
 boolean isLuceneInputMode()
          Get the flag if current input mode for JTextField is lucene input mode.
 void setFromEnd(boolean fromEnd)
          Sets the fromEnd property.
 void setFromStart(boolean fromStart)
          Sets the fromStart property.
static void setLuceneHelpURL(String luceneHelpURL)
          Deprecated. please use LuceneFilterMenuSupport.setLuceneHelpURL(String) instead
 void setLuceneInputMode(boolean luceneInputMode)
          Set the flag if current input mode for JTextField is lucene input mode.
 void setTableModel(TableModel tableModel)
          Sets the table model used by this component.
 
Methods inherited from class com.jidesoft.grid.QuickTableFilterField
addFilter, applyFilter, changeFilter, compare, convertElementToString, createDisplayTableModel, createFilter, createFilterChooserDialog, getActualSearchingColumnIndices, getColumnIndices, getDisplayNames, getDisplayTableModel, getSearchingColumnIndex, getSearchingColumnIndices, getTable, getTableModel, isConfigurationChanged, isObjectConverterManagerEnabled, isSearchingAllColumns, propertyChange, removeFilter, setColumnIndices, setConfigurationChanged, setDisplayNames, setObjectConverterManagerEnabled, setSearchingColumnIndex, setSearchingColumnIndices, setTable, shouldColumnBeIncluded, tableChanged
 
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, 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
 

Constructor Detail

LuceneQuickTableFilterField

public LuceneQuickTableFilterField()
Creates an empty LuceneQuickTableFilterField. This method is useless since LuceneQuickTableFilterField 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 LuceneQuickTableFilterField using this constructor.


LuceneQuickTableFilterField

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

Parameters:
tableModel - the TableModel

LuceneQuickTableFilterField

public LuceneQuickTableFilterField(TableModel tableModel,
                                   int[] columnIndices)
Creates a LuceneQuickTableFilterField 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.

LuceneQuickTableFilterField

public LuceneQuickTableFilterField(TableModel tableModel,
                                   int[] columnIndices,
                                   String[] displayNames)
Creates a LuceneQuickTableFilterField 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

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.

Overrides:
setTableModel in class QuickTableFilterField
Parameters:
tableModel - the TableModel

createFilterableTableModel

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

Please be noted that so far we don't support TreeTableModel work with lucene.

Overrides:
createFilterableTableModel in class QuickTableFilterField
Parameters:
tableModel - the actual table model.
Returns:
an IFilterableTableModel, which has to be LuceneFilterableTableModel.

getLuceneDocumentProvider

public com.jidesoft.lucene.LuceneDocumentProvider getLuceneDocumentProvider()

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 QuickTableFilterField
Returns:
the context menu.

applyFilter

public void applyFilter(String text)
Description copied from class: QuickTableFilterField
Applies the filter.

Overrides:
applyFilter in class QuickTableFilterField
Parameters:
text - the searching text.

setFromStart

public void setFromStart(boolean fromStart)
Description copied from class: QuickFilterField
Sets the fromStart property.

Overrides:
setFromStart in class QuickFilterField
Parameters:
fromStart - true if the comparison matches from the start of the text only. Otherwise false. The difference is if true, it will use String's startWith method to match. If false, it will use indedxOf method.

setFromEnd

public void setFromEnd(boolean fromEnd)
Description copied from class: QuickFilterField
Sets the fromEnd property.

Overrides:
setFromEnd in class QuickFilterField
Parameters:
fromEnd - true if the comparison matches from the end of the text only. Otherwise false. The difference is if true, it will use String's endWith method to match. If false, it will use indedxOf method.

isLuceneInputMode

public boolean isLuceneInputMode()
Get the flag if current input mode for JTextField is lucene input mode.

Returns:
the flag.

setLuceneInputMode

public void setLuceneInputMode(boolean luceneInputMode)
Set the flag if current input mode for JTextField is lucene input mode.

Parameters:
luceneInputMode - the flag

getLuceneHelpURL

@Deprecated
public static String getLuceneHelpURL()
Deprecated. please use LuceneFilterMenuSupport.getLuceneHelpURL() instead

Get the URL link for lucene query syntax on-line document.

The default link is http://lucene.apache.org/core/2_9_4/queryparsersyntax.html

Returns:
the URL link.

setLuceneHelpURL

@Deprecated
public static void setLuceneHelpURL(String luceneHelpURL)
Deprecated. please use LuceneFilterMenuSupport.setLuceneHelpURL(String) instead

Set the URL link for lucene query syntax on-line document.

Parameters:
luceneHelpURL - the URL link

getTextField

public JTextField getTextField()

getResourceString

public String getResourceString(String key)

JIDE 3.5.15