protected int getCurrentIndex() { if (_selection.contains(getSelectedIndex())) { return _cursor != -1 ? _cursor : getSelectedIndex(); } else { _selection.clear(); return getSelectedIndex(); } }
/** * Highlight all matching cases in the target. * <p/> * In default implementation, it will just search all texts in the target to highlight all. If you have a really * huge text to search, you may want to override this method to have a lazy behavior on visible areas only. */ protected void highlightAll() { int firstIndex = -1; int index = getSelectedIndex(); String text = getSearchingText(); while (index != -1) { int newIndex = findNext(text); if (index == newIndex) { index = -1; } else { index = newIndex; } if (index != -1) { if (firstIndex == -1) { firstIndex = index; } select(index, text); } } // now select the first one if (firstIndex != -1) { select(firstIndex, text); } }
private void setInitValue() { int index = getSearchable().getSelectedIndex(); if (index != -1) { Object selected = getSearchable().getElementAt(index); if (selected != null) _document.setText(getSearchable().convertElementToString(selected)); highlightCompletedText(0); } else { _document.setText(""); } }
public void actionPerformed(ActionEvent e) { _highlightsButton.setSelected(false); String text = getSearchingText(); addSearchingTextToHistory(text); int cursor = _searchable.getSelectedIndex(); _searchable.setCursor(cursor); int found = _searchable.findPrevious(text); if (found == cursor) { select(found, text, false); clearStatus(); } else if (found != -1 && _searchable.isRepeats() && found >= cursor) { select(found, text, false); setStatus(getResourceString("SearchableBar.reachedTopRepeat"), getImageIcon(SearchableBarIconsFactory.Buttons.REPEAT)); } else if (!_searchable.isRepeats() && found == -1) { setStatus(getResourceString("SearchableBar.reachedTop"), getImageIcon(SearchableBarIconsFactory.Buttons.ERROR)); } else if (found != -1) { select(found, text, false); clearStatus(); } } };
index = getSearchable().getSelectedIndex(); if (index == -1) { if (getSearchable().getElementCount() > 0) { index = getSearchable().getSelectedIndex(); if (index == -1) { if (getSearchable().getElementCount() > 0) {
public void actionPerformed(ActionEvent e) { _highlightsButton.setSelected(false); String text = getSearchingText(); addSearchingTextToHistory(text); int cursor = _searchable.getSelectedIndex(); _searchable.setCursor(cursor); int found = _searchable.findNext(text); if (found == cursor) { select(found, text, false); clearStatus(); } else if (found != -1 && _searchable.isRepeats() && found <= cursor) { select(found, text, false); setStatus(getResourceString("SearchableBar.reachedBottomRepeat"), getImageIcon(SearchableBarIconsFactory.Buttons.REPEAT)); } else if (!_searchable.isRepeats() && found == -1) { setStatus(getResourceString("SearchableBar.reachedBottom"), getImageIcon(SearchableBarIconsFactory.Buttons.ERROR)); } else if (found != -1) { select(found, text, false); clearStatus(); if (_searchable.getSearchingDelay() < 0) { // never updated the count so we update here highlightAllOrNext(); } } } };