/**
  * Sets which elements are grayed in this viewer's tree. The given list contains the elements that
  * are to be grayed; all other elements are to be ungrayed.
  *
  * <p>This method is typically used when restoring the interesting state of a viewer captured by
  * an earlier call to <code>getGrayedElements</code>.
  *
  * @param elements the array of grayed elements
  * @see #getGrayedElements
  */
 public void setGrayedElements(Object[] elements) {
   assertElementsNotNull(elements);
   CustomHashtable grayedElements = newHashtable(elements.length * 2 + 1);
   for (int i = 0; i < elements.length; ++i) {
     Object element = elements[i];
     // Ensure item exists for element
     internalExpand(element, false);
     grayedElements.put(element, element);
   }
   Control tree = getControl();
   tree.setRedraw(false);
   internalSetGrayed(grayedElements, tree);
   tree.setRedraw(true);
 }
 /**
  * Sets the grayed state of all items to correspond to the given set of grayed elements.
  *
  * @param grayedElements the set (element type: <code>Object</code>) of elements which are grayed
  * @param widget the widget
  */
 private void internalSetGrayed(CustomHashtable grayedElements, Widget widget) {
   Item[] items = getChildren(widget);
   for (int i = 0; i < items.length; i++) {
     TreeItem item = (TreeItem) items[i];
     Object data = item.getData();
     if (data != null) {
       boolean grayed = grayedElements.containsKey(data);
       if (grayed != item.getGrayed()) {
         item.setGrayed(grayed);
       }
     }
     internalSetGrayed(grayedElements, item);
   }
 }