public abstract class SpeedSearchBase<Comp extends javax.swing.JComponent> extends SpeedSearchSupply
Modifier and Type | Class and Description |
---|---|
protected class |
SpeedSearchBase.ViewIterator |
Modifier and Type | Field and Description |
---|---|
protected Comp |
myComponent |
ENTERED_PREFIX_PROPERTY_NAME, SEARCH_QUERY_KEY, SPEED_SEARCH_CURRENT_QUERY
Constructor and Description |
---|
SpeedSearchBase(Comp component) |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(java.beans.PropertyChangeListener listener) |
boolean |
adjustSelection(int keyCode,
java.lang.String searchQuery) |
protected boolean |
compare(java.lang.String text,
java.lang.String pattern) |
protected int |
convertIndexToModel(int viewIndex)
Should convert given view index to model index
|
void |
findAndSelectElement(java.lang.String searchQuery)
Find an element matching the searching query in the underlying component and select it there.
|
protected java.lang.Object |
findElement(java.lang.String s) |
protected abstract java.lang.Object [] |
getAllElements() |
SpeedSearchComparator |
getComparator() |
Comp |
getComponent() |
protected java.awt.Point |
getComponentLocationOnScreen() |
protected java.awt.Rectangle |
getComponentVisibleRect() |
protected int |
getElementCount() |
protected java.util.ListIterator<java.lang.Object> |
getElementIterator(int startingIndex) |
protected abstract java.lang.String |
getElementText(java.lang.Object element) |
java.lang.String |
getEnteredPrefix() |
javax.swing.JTextField |
getSearchField() |
protected abstract int |
getSelectedIndex()
Returns visual (view) selection index.
|
static boolean |
hasActiveSpeedSearch(javax.swing.JComponent component) |
void |
hidePopup() |
protected boolean |
isMatchingElement(java.lang.Object element,
java.lang.String pattern) |
boolean |
isPopupActive() |
protected boolean |
isSpeedSearchEnabled() |
java.lang.Iterable<TextRange> |
matchingFragments(java.lang.String text) |
protected void |
onSearchFieldUpdated(java.lang.String pattern) |
protected void |
processKeyEvent(java.awt.event.KeyEvent e) |
void |
refreshSelection()
Selects element according to search criteria changes
|
void |
removeChangeListener(java.beans.PropertyChangeListener listener) |
protected abstract void |
selectElement(java.lang.Object element,
java.lang.String selectedText) |
void |
setClearSearchOnNavigateNoMatch(boolean clearSearchOnNavigateNoMatch) |
void |
setComparator(SpeedSearchComparator comparator) |
void |
showPopup() |
void |
showPopup(java.lang.String searchText) |
getSupply, getSupply, installSupplyTo
protected final Comp extends javax.swing.JComponent myComponent
public SpeedSearchBase(Comp component)
public javax.swing.JTextField getSearchField()
public static boolean hasActiveSpeedSearch(javax.swing.JComponent component)
public void setClearSearchOnNavigateNoMatch(boolean clearSearchOnNavigateNoMatch)
public boolean isPopupActive()
isPopupActive
in class SpeedSearchSupply
public java.lang.Iterable<TextRange> matchingFragments(java.lang.String text)
matchingFragments
in class SpeedSearchSupply
protected abstract int getSelectedIndex()
protected abstract java.lang.Object [] getAllElements()
protected abstract java.lang.String getElementText(java.lang.Object element)
protected int getElementCount()
protected int convertIndexToModel(int viewIndex)
protected abstract void selectElement(java.lang.Object element, java.lang.String selectedText)
element
- Element to select. Don't forget to convert model index to view index if needed (i.e. table.convertRowIndexToView(modelIndex), etc).selectedText
- search textprotected java.util.ListIterator<java.lang.Object> getElementIterator(int startingIndex)
public void addChangeListener(java.beans.PropertyChangeListener listener)
addChangeListener
in class SpeedSearchSupply
public void removeChangeListener(java.beans.PropertyChangeListener listener)
removeChangeListener
in class SpeedSearchSupply
protected boolean isMatchingElement(java.lang.Object element, java.lang.String pattern)
protected boolean compare(java.lang.String text, java.lang.String pattern)
public SpeedSearchComparator getComparator()
public void setComparator(SpeedSearchComparator comparator)
protected java.lang.Object findElement(java.lang.String s)
public void showPopup(java.lang.String searchText)
public void showPopup()
public void hidePopup()
protected void processKeyEvent(java.awt.event.KeyEvent e)
public Comp getComponent()
protected boolean isSpeedSearchEnabled()
public java.lang.String getEnteredPrefix()
getEnteredPrefix
in class SpeedSearchSupply
public void refreshSelection()
SpeedSearchSupply
refreshSelection
in class SpeedSearchSupply
public void findAndSelectElement(java.lang.String searchQuery)
SpeedSearchSupply
findAndSelectElement
in class SpeedSearchSupply
searchQuery
- text that the selected element should matchpublic boolean adjustSelection(int keyCode, java.lang.String searchQuery)
protected void onSearchFieldUpdated(java.lang.String pattern)
protected java.awt.Rectangle getComponentVisibleRect()
protected java.awt.Point getComponentLocationOnScreen()