/**
  * Sets the checked state for the given element and its visible children in this viewer. Assumes
  * that the element has been expanded before. To enforce that the item is expanded, call <code>
  * expandToLevel</code> for the element. Does not fire events to check state listeners.
  *
  * @param element the element
  * @param state <code>true</code> if the item should be checked, and <code>false</code> if it
  *     should be unchecked
  * @return <code>true</code> if the checked state could be set, and <code>false</code> otherwise
  */
 public boolean setSubtreeChecked(Object element, boolean state) {
   Widget widget = internalExpand(element, false);
   if (widget instanceof TreeItem) {
     TreeItem item = (TreeItem) widget;
     item.setChecked(state);
     setCheckedChildren(item, state);
     return true;
   }
   return false;
 }
 /**
  * Sets the checked state for the children of the given item.
  *
  * @param item the item
  * @param state <code>true</code> if the item should be checked, and <code>false</code> if it
  *     should be unchecked
  */
 private void setCheckedChildren(Item item, boolean state) {
   createChildren(item);
   Item[] items = getChildren(item);
   if (items != null) {
     for (int i = 0; i < items.length; i++) {
       Item it = items[i];
       if (it.getData() != null && (it instanceof TreeItem)) {
         TreeItem treeItem = (TreeItem) it;
         treeItem.setChecked(state);
         setCheckedChildren(treeItem, state);
       }
     }
   }
 }