/**
   * Internal hook method called when the input to this viewer is initially set or subsequently
   * changed.
   *
   * <p>The <code>ContentMergeViewer</code> implementation of this <code>Viewer</code> method tries
   * to save the old input by calling <code>doSave(...)</code> and then calls <code>
   * internalRefresh(...)</code> .
   *
   * @param input the new input of this viewer, or <code>null</code> if there is no new input
   * @param oldInput the old input element, or <code>null</code> if there was previously no input
   */
  protected final void inputChanged(Object input, Object oldInput) {

    if (input != oldInput && oldInput != null) {
      ICompareInputLabelProvider lp = getCompareConfiguration().getLabelProvider();
      if (lp != null) lp.removeListener(labelChangeListener);
    }

    if (input != oldInput && oldInput instanceof ICompareInput) {
      ICompareContainer container = getCompareConfiguration().getContainer();
      container.removeCompareInputChangeListener(
          (ICompareInput) oldInput, fCompareInputChangeListener);
    }

    boolean success = doSave(input, oldInput);

    if (input != oldInput && input instanceof ICompareInput) {
      ICompareContainer container = getCompareConfiguration().getContainer();
      container.addCompareInputChangeListener((ICompareInput) input, fCompareInputChangeListener);
    }

    if (input != oldInput && input != null) {
      ICompareInputLabelProvider lp = getCompareConfiguration().getLabelProvider();
      if (lp != null) lp.addListener(labelChangeListener);
    }

    if (success) {
      setLeftDirty(false);
      setRightDirty(false);
    }

    if (input != oldInput) internalRefresh(input);
  }