Ejemplo n.º 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();
 }
Ejemplo n.º 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);
      }
    }
  }
Ejemplo n.º 3
0
  private void initLivePreview() {
    myLivePreviewController.on();

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

    mySearchResults.addListener(this);
  }
Ejemplo n.º 4
0
  @Override
  public void removeNotify() {
    super.removeNotify();

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

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