/* (non-Javadoc)
   * Method declared on Viewer.
   */
  protected void preservingSelection(Runnable updateCode) {
    if (!getPreserveSelection()) {
      return;
    }
    // If a check provider is present, it determines the state across input
    // changes.
    if (checkStateProvider != null) {
      // Try to preserve the selection, let the ICheckProvider manage
      // the check states
      super.preservingSelection(updateCode);
      return;
    }

    // Preserve checked items
    int n = getItemCount(getControl());
    CustomHashtable checkedNodes = newHashtable(n * 2 + 1);
    CustomHashtable grayedNodes = newHashtable(n * 2 + 1);

    gatherState(checkedNodes, grayedNodes, getControl());

    super.preservingSelection(updateCode);

    applyState(checkedNodes, grayedNodes, getControl());
  }