Beispiel #1
0
 @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();
 }
Beispiel #2
0
  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);
      }
    }
  }
Beispiel #3
0
  private void initLivePreview() {
    myLivePreviewController.on();

    myLivePreviewController.setUserActivityDelay(0);
    updateResults(false);
    myLivePreviewController.setUserActivityDelay(
        LivePreviewController.USER_ACTIVITY_TRIGGERING_DELAY);

    mySearchResults.addListener(this);
  }
Beispiel #4
0
  @Override
  public void removeNotify() {
    super.removeNotify();

    myLivePreviewController.off();
    mySearchResults.removeListener(this);

    addTextToRecent(mySearchTextComponent);
    if (myReplaceTextComponent != null) {
      addTextToRecent(myReplaceTextComponent);
    }
  }
Beispiel #5
0
 public void addNextOccurrence() {
   mySearchResults.nextOccurrence(true);
 }
Beispiel #6
0
 public void removeOccurrence() {
   mySearchResults.prevOccurrence(true);
 }
Beispiel #7
0
 public void selectAllOccurrences() {
   FindUtil.selectSearchResultsInEditor(myEditor, mySearchResults.getOccurrences().iterator(), -1);
 }
Beispiel #8
0
 public boolean hasMatches() {
   return mySearchResults != null && mySearchResults.hasMatches();
 }
Beispiel #9
0
 private void nothingToSearchFor() {
   updateUIWithEmptyResults();
   if (mySearchResults != null) {
     mySearchResults.clear();
   }
 }
Beispiel #10
0
 public void replaceCurrent() {
   if (mySearchResults.getCursor() != null) {
     myLivePreviewController.performReplace();
   }
 }
Beispiel #11
0
 private void setMatchesLimit(int value) {
   mySearchResults.setMatchesLimit(value);
 }