public void setLivePreview(LivePreview livePreview) {
   if (myLivePreview != null) {
     myLivePreview.dispose();
     myLivePreview.setDelegate(null);
   }
   myLivePreview = livePreview;
   if (myLivePreview != null) {
     myLivePreview.setDelegate(this);
   }
 }
  public void dispose() {
    if (myDisposed) return;

    myLivePreview.cleanUp();
    off();

    mySearchResults.dispose();
    getEditor().getDocument().removeDocumentListener(myDocumentListener);
    myDisposed = true;
  }
 @Nullable
 public TextRange performReplace(
     final FindResult occurrence, final String replacement, final Editor editor) {
   if (myReplaceDenied
       || !ReadonlyStatusHandler.ensureDocumentWritable(editor.getProject(), editor.getDocument()))
     return null;
   FindModel findModel = mySearchResults.getFindModel();
   TextRange result =
       FindUtil.doReplace(
           editor.getProject(),
           editor.getDocument(),
           findModel,
           new FindResultImpl(occurrence.getStartOffset(), occurrence.getEndOffset()),
           replacement,
           true,
           new ArrayList<Pair<TextRange, String>>());
   myLivePreview.inSmartUpdate();
   mySearchResults.updateThreadSafe(findModel, true, result, mySearchResults.getStamp());
   return result;
 }
 private void smartUpdate() {
   myLivePreview.inSmartUpdate();
   updateInBackground(mySearchResults.getFindModel(), false);
 }