|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.jidesoft.swing.LabeledTextField com.jidesoft.grid.QuickFilterField
public abstract class QuickFilterField
QuickFilterField
is an abstract class which can provide filter function to JList, JTable or JTree.
setSearchingDelay(int)
. If you set it to -1, it will filter only if user presses ENTER key.
You can listen to property change event of PROPERTY_SEARCH_TEXT
to detect any text change programmatically.
The abstract method applyFilter(String)
will be implemented by subclasses to implement the filtering
feature.
Nested Class Summary | |
---|---|
class |
QuickFilterField.FieldFilter
This class is a subclass of Filter for QuickFilterField internal use. |
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 Filter |
_filter
|
protected String |
_searchingText
|
static String |
PROPERTY_CASE_SENSITIVE
|
static String |
PROPERTY_FROM_END
|
static String |
PROPERTY_FROM_START
|
static String |
PROPERTY_REGEX_ENABLED
|
static String |
PROPERTY_SEARCH_TEXT
|
static String |
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 | |
---|---|
QuickFilterField()
Creates an empty QuickFilterField . |
Method Summary | |
---|---|
protected void |
adjustMismatchColor(boolean hasMatch)
Adjusts background for the filter field to indicate if there is any matching record. |
void |
applyFilter()
|
abstract void |
applyFilter(String text)
Applies the filter. |
protected boolean |
compare(Object element,
String searchingText)
Checks if the element matches the searching text. |
protected boolean |
compare(String text,
String searchingText)
Checks if the element string matches the searching text. |
protected String |
convertElementToString(Object element)
Converts the element from Object to string. |
protected AbstractButton |
createButton()
Creates the button that appears after the text field. |
protected JidePopupMenu |
createContextMenu()
Creates the context menu. |
protected Filter |
createFilter()
Creates the filter that will be used in applyFilter(String) method. |
static Icon |
getDefaultFilterIcon()
|
static Icon |
getDefaultResetIcon()
|
static Icon |
getDefaultResetRolloverIcon()
|
Filter |
getFilter()
|
Icon |
getFilterIcon()
Gets the filter icon. |
Color |
getMismatchColor()
Get the background color when the searching text doesn't match with any of the elements in the component. |
Icon |
getResetIcon()
Gets the reset icon. |
Icon |
getResetRolloverIcon()
Gets the reset icon when rollover. |
String |
getResourceString(String key)
Gets the localized string from resource bundle. |
int |
getSearchingDelay()
If it returns a positive number, it will wait for that many ms before doing the search. |
String |
getSearchingText()
Gets the searching text. |
WildcardSupport |
getWildcardSupport()
Gets the WildcardSupport. |
protected void |
initComponent()
|
void |
installListeners()
|
boolean |
isCaseSensitive()
Checks if it used case sensitive search. |
protected boolean |
isConfigurationChanged()
Get the flag indicating if the configure like case sensitive of the QuickFilterField is changed. |
boolean |
isFromEnd()
This is a property of how to compare searching text with the data. |
boolean |
isFromStart()
This is a property of how to compare searching text with the data. |
boolean |
isRegexEnabled()
Get the flag if regular expression is used for searching. |
boolean |
isShowMismatchColor()
Get the flag indicating if the filter field should change color to indicate the current searching result. |
boolean |
isWildcardEnabled()
Checks if it supports wildcard in searching text. |
boolean |
matches(Object element,
String searchingText)
Checks if the element matches the searching text. |
void |
setCaseSensitive(boolean caseSensitive)
Sets the case sensitive flag. |
protected void |
setConfigurationChanged(boolean configureChanged)
Set the flag indicating if the configure like case sensitive of the QuickFilterField is changed. |
static void |
setDefaultFilterIcon(Icon defaultFilterIcon)
|
static void |
setDefaultResetIcon(Icon defaultResetIcon)
|
static void |
setDefaultResetRolloverIcon(Icon defaultResetRolloverIcon)
|
void |
setFilterIcon(Icon filterIcon)
Sets the filter icon. |
void |
setFromEnd(boolean fromEnd)
Sets the fromEnd property. |
void |
setFromStart(boolean fromStart)
Sets the fromStart property. |
void |
setMismatchColor(Color mismatchColor)
Set the color for mismatch. |
void |
setRegexEnabled(boolean regexEnabled)
Set the flag if regular expression is used for searching. |
void |
setResetIcon(Icon resetIcon)
Sets the reset icon. |
void |
setResetRolloverIcon(Icon icon)
Sets the reset icon when rollover. |
void |
setSearchingDelay(int searchingDelay)
If this flag is set to a positive number, it will wait for that many ms before doing the search. |
void |
setSearchingText(String text)
Sets the searching text. |
void |
setShowMismatchColor(boolean showMismatchColor)
Set the flag indicating if the filter field should change color to indicate the current searching result. |
void |
setWildcardEnabled(boolean wildcardEnabled)
Enable or disable the usage of wildcard. |
void |
setWildcardSupport(WildcardSupport wildcardSupport)
Sets the WildcardSupport. |
void |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String PROPERTY_SEARCH_TEXT
public static final String PROPERTY_CASE_SENSITIVE
public static final String PROPERTY_WILDCARD_ENABLED
public static final String PROPERTY_REGEX_ENABLED
public static final String PROPERTY_FROM_START
public static final String PROPERTY_FROM_END
protected Filter _filter
protected String _searchingText
Constructor Detail |
---|
public QuickFilterField()
QuickFilterField
. This method is useless since QuickFilterField
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 corresponding set model method after you create QuickFilterField
using
this constructor.
Method Detail |
---|
public int getSearchingDelay()
public void setSearchingDelay(int searchingDelay)
searchingDelay
- the number of ms delay before searching start.protected void initComponent()
initComponent
in class LabeledTextField
public void installListeners()
public void uninstallListeners()
public static Icon getDefaultResetIcon()
public static void setDefaultResetIcon(Icon defaultResetIcon)
public static Icon getDefaultFilterIcon()
public static void setDefaultFilterIcon(Icon defaultFilterIcon)
public static Icon getDefaultResetRolloverIcon()
public static void setDefaultResetRolloverIcon(Icon defaultResetRolloverIcon)
public Icon getResetIcon()
setResetIcon(javax.swing.Icon)
to set a
new one.
public void setResetIcon(Icon resetIcon)
resetIcon
- the reset icon.public Icon getResetRolloverIcon()
public void setResetRolloverIcon(Icon icon)
icon
- the reset icon when rollover.public Icon getFilterIcon()
setFilterIcon(javax.swing.Icon)
to set a new one.
public void setFilterIcon(Icon filterIcon)
filterIcon
- the filter iconprotected AbstractButton createButton()
LabeledTextField
createButton
in class LabeledTextField
protected Filter createFilter()
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.
public Filter getFilter()
protected JidePopupMenu createContextMenu()
JideSwingUtilities.findFirstComponentByName(java.awt.Container, String)
. The names are "Filter.caseSensitive",
"Filter.caseInsensitive", "Filter.matchFromStart" and "Filter.matchAnywhere" respectively.
createContextMenu
in class LabeledTextField
public abstract void applyFilter(String text)
text
- the searching text.public void applyFilter()
protected void setConfigurationChanged(boolean configureChanged)
configureChanged
- the flagprotected boolean isConfigurationChanged()
applyFilter()
is invoked.
protected String convertElementToString(Object element)
compare(Object, String)
to
convert the first parameter to string then call compare(String, String)
to do the comparison.
You can subclass and override this method to do your own conversion if needed.
element
- the element to be converted to string.
protected boolean compare(Object element, String searchingText)
element
- the element to be compared.searchingText
- the text in the QuickFilterField
.
public boolean matches(Object element, String searchingText)
compare(Object, String)
but
we need a public API so that user can call it to figure out if the element matches with the searching text from
outside.
element
- the element to be compared.searchingText
- the text in the QuickFilterField
.
protected boolean compare(String text, String searchingText)
compare(Object, String)
, this
method is after the element has been converted to string using convertElementToString(Object)
.
Here is the default implementation in case you need to provide your own way to compare.
return searchingText == null || (isFromStart() ? elementText.startsWith(searchingText) :
elementText.indexOf(searchingText) != -1);
text
- the text converted from the element.searchingText
- the text in the QuickFilterField
.
public boolean isCaseSensitive()
public void setCaseSensitive(boolean caseSensitive)
caseSensitive
- true if you want the filtering to be case sensitive. Otherwise false.public boolean isFromStart()
String.startsWith(String)
to do the comparison. Otherwise, it will use String.indexOf(String)
to do the
comparison.
public void setFromStart(boolean fromStart)
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.public boolean isFromEnd()
String.endsWith(String)
to do the comparison. Otherwise, it will use String.indexOf(String)
to do the
comparison.
public void setFromEnd(boolean fromEnd)
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.public void setSearchingText(String text)
text
- the searching text.public String getSearchingText()
public String getResourceString(String key)
key
- the key to the resource.
public boolean isWildcardEnabled()
setRegexEnabled(boolean)
public void setWildcardEnabled(boolean wildcardEnabled)
wildcardEnabled
- true or falseisWildcardEnabled()
public boolean isRegexEnabled()
public void setRegexEnabled(boolean regexEnabled)
regexEnabled
- the flagisRegexEnabled()
,
setWildcardEnabled(boolean)
public WildcardSupport getWildcardSupport()
DefaultWildcardSupport
will be used.
public void setWildcardSupport(WildcardSupport wildcardSupport)
wildcardSupport
- the new WildCardSupport.protected void adjustMismatchColor(boolean hasMatch)
hasMatch
- if there is any match record with current searching text.public Color getMismatchColor()
setMismatchColor(java.awt.Color)
. red color
will be used.public void setMismatchColor(Color mismatchColor)
mismatchColor
- the mismatch colorpublic boolean isShowMismatchColor()
public void setShowMismatchColor(boolean showMismatchColor)
showMismatchColor
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |