@Override public void searchResultsUpdated(SearchResults sr) { if (mySearchTextComponent.getText().isEmpty()) { updateUIWithEmptyResults(); } else { int count = sr.getMatchesCount(); boolean notTooMuch = count <= mySearchResults.getMatchesLimit(); myMatchInfoLabel.setText( notTooMuch ? ApplicationBundle.message("editorsearch.matches", count) : ApplicationBundle.message( "editorsearch.toomuch", mySearchResults.getMatchesLimit())); myClickToHighlightLabel.setVisible(!notTooMuch); if (notTooMuch) { if (count > 0) { setRegularBackground(); } else { setNotFoundBackground(); } } else { setRegularBackground(); } } myReplaceActionsToolbar1.updateActionsImmediately(); }
private void updateResults(final boolean allowedToChangedEditorSelection) { final String text = myFindModel.getStringToFind(); if (text.length() == 0) { nothingToSearchFor(); } else { if (myFindModel.isRegularExpressions()) { try { Pattern.compile(text); } catch (Exception e) { setNotFoundBackground(); myClickToHighlightLabel.setVisible(false); mySearchResults.clear(); myMatchInfoLabel.setText("Incorrect regular expression"); return; } } final FindManager findManager = FindManager.getInstance(myProject); if (allowedToChangedEditorSelection) { findManager.setFindWasPerformed(); FindModel copy = new FindModel(); copy.copyFrom(myFindModel); copy.setReplaceState(false); findManager.setFindNextModel(copy); } if (myLivePreviewController != null) { myLivePreviewController.updateInBackground(myFindModel, allowedToChangedEditorSelection); } } }
private void initLivePreview() { myLivePreviewController.on(); myLivePreviewController.setUserActivityDelay(0); updateResults(false); myLivePreviewController.setUserActivityDelay( LivePreviewController.USER_ACTIVITY_TRIGGERING_DELAY); mySearchResults.addListener(this); }
@Override public void removeNotify() { super.removeNotify(); myLivePreviewController.off(); mySearchResults.removeListener(this); addTextToRecent(mySearchTextComponent); if (myReplaceTextComponent != null) { addTextToRecent(myReplaceTextComponent); } }
public void addNextOccurrence() { mySearchResults.nextOccurrence(true); }
public void removeOccurrence() { mySearchResults.prevOccurrence(true); }
public void selectAllOccurrences() { FindUtil.selectSearchResultsInEditor(myEditor, mySearchResults.getOccurrences().iterator(), -1); }
public boolean hasMatches() { return mySearchResults != null && mySearchResults.hasMatches(); }
private void nothingToSearchFor() { updateUIWithEmptyResults(); if (mySearchResults != null) { mySearchResults.clear(); } }
public void replaceCurrent() { if (mySearchResults.getCursor() != null) { myLivePreviewController.performReplace(); } }
private void setMatchesLimit(int value) { mySearchResults.setMatchesLimit(value); }