/**
   * The viewer is no longer part of the UI, it's a wrapper only. The disposal doesn't take place
   * while releasing the editor pane's children. The method have to be called it manually. The
   * wrapped viewer is disposed as a regular viewer, while disposing the UI.
   */
  public void dispose() {
    getSourceViewer().removeTextListener(this);
    getSourceViewer().removeSelectionChangedListener(this);
    EditorsUI.getPreferenceStore().removePropertyChangeListener(fPreferenceChangeListener);

    IOperationHistory history = getHistory();
    if (history != null) history.removeOperationHistoryListener(this);
  }
  @Override
  public void dispose() {

    IOperationHistory history = getHistory();
    if (history != null) {
      history.removeOperationHistoryListener(historyListener);
    }

    if (isInvalid()) {
      return;
    }

    site.getPage().removePartListener(partListener);
    site = null;
    progressDialog = null;
    // We do not flush the history for our undo context because it may be
    // used elsewhere. It is up to clients to clean up the history
    // appropriately.
    // We do null out the context to signify that this handler is no longer
    // accessing the history.
    undoContext = null;
  }