/**
  * Set the checked state of the visible items and their children to state.
  *
  * @param state
  * @param items
  * @deprecated
  * @see #setAllChecked(boolean)
  */
 private void setAllChecked(boolean state, TreeItem[] items) {
   for (int i = 0; i < items.length; i++) {
     items[i].setChecked(state);
     TreeItem[] children = items[i].getItems();
     setAllChecked(state, children);
   }
 }
Пример #2
0
  public void testSetAllChecked() {
    CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;

    ctv.expandToLevel(2);

    ctv.setAllChecked(true);
    Object[] expandedElements = ctv.getExpandedElements();

    for (int i = 0; i < expandedElements.length; i++) {
      assertTrue("all expanded items should be checked", ctv.getChecked(expandedElements[i]));
    }

    ctv.setAllChecked(false);

    for (int i = 0; i < expandedElements.length; i++) {
      assertFalse("all expanded items should be unchecked", ctv.getChecked(expandedElements[i]));
    }
  }
 /**
  * Sets to the given value the checked state for all elements in this viewer. Does not fire events
  * to check state listeners. Assumes that the element has been expanded before. To enforce that
  * the item is expanded, call <code>expandToLevel</code> for the element.
  *
  * @param state <code>true</code> if the element should be checked, and <code>false</code> if it
  *     should be unchecked
  * @deprecated as this method only checks or unchecks visible items is is recommended that {@link
  *     #setSubtreeChecked(Object, boolean)} is used instead.
  * @see #setSubtreeChecked(Object, boolean)
  * @since 1.0
  */
 public void setAllChecked(boolean state) {
   setAllChecked(state, getTree().getItems());
 }