public void firePropertyChangeEvent(String searchingText) { if (!searchingText.equals(_previousSearchText)) { _propertyChangeSupport.firePropertyChange(PROPERTY_SEARCH_TEXT, _previousSearchText, searchingText); fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_CHANGE, searchingText, getCurrentIndex(), _previousSearchText)); _previousSearchText = searchingText; if (searchingText.length() == 0) { searchingTextEmpty(); } } }
private void highlightAllOrNext() { if (_highlightsButton.isSelected()) { _previousCursor = _searchable.getCurrentIndex(); highlightAll(); } else { if (_previousCursor >= 0) { _searchable.setCursor(_previousCursor); _searchable.setSelectedIndex(_previousCursor, false); } highlightNext(); } }
/** * Finds the next matching index from the cursor. * * @param s the searching text * @return the next index that the element matches the searching text. */ public int findNext(String s) { String str = isCaseSensitive() ? s : s.toLowerCase(); int count = getElementCount(); if (count == 0) return s.length() > 0 ? -1 : 0; int selectedIndex = getCurrentIndex(); for (int i = selectedIndex + 1; i < count; i++) { Object element = getElementAt(i); if (compare(element, str)) return i; } if (isRepeats()) { for (int i = 0; i < selectedIndex; i++) { Object element = getElementAt(i); if (compare(element, str)) return i; } } return selectedIndex == -1 ? -1 : (compare(getElementAt(selectedIndex), str) ? selectedIndex : -1); }
/** * Finds the previous matching index from the cursor. * * @param s the searching text * @return the previous index that the element matches the searching text. */ public int findPrevious(String s) { String str = isCaseSensitive() ? s : s.toLowerCase(); int count = getElementCount(); if (count == 0) return s.length() > 0 ? -1 : 0; int selectedIndex = getCurrentIndex(); for (int i = selectedIndex - 1; i >= 0; i--) { Object element = getElementAt(i); if (compare(element, str)) return i; } if (isRepeats()) { for (int i = count - 1; i >= selectedIndex; i--) { Object element = getElementAt(i); if (compare(element, str)) return i; } } return selectedIndex == -1 ? -1 : (compare(getElementAt(selectedIndex), str) ? selectedIndex : -1); }
int selectedIndex = getCurrentIndex(); if (selectedIndex < 0) selectedIndex = 0;
/** * Hides the popup. */ public void hidePopup() { if (_popup != null) { if (isHeavyweightComponentEnabled()) { _popup.hidePopupImmediately(); } else { if (_layeredPane != null) { _layeredPane.remove(_popup); _layeredPane.validate(); _layeredPane.repaint(); _layeredPane = null; } } _popup = null; _searchableProvider = null; _previousSearchText = null; fireSearchableEvent(new SearchableEvent(Searchable.this, SearchableEvent.SEARCHABLE_END, "", getCurrentIndex(), _previousSearchText)); } setCursor(-1); }
boolean reverse = isReverseOrder(); setReverseOrder(false); int selectedIndex = getCurrentIndex(); if (selectedIndex < 0) { selectedIndex = 0; int selectedIndex = getCurrentIndex(); if (selectedIndex < 0) selectedIndex = 0;