コード例 #1
0
  /**
   * Restores the checked state of items based on the cached check state. This will only check leaf
   * nodes, but parent items will be updated by the container viewer. No events will be fired.
   */
  public void restoreLeafCheckState() {
    if (checkState == null) return;

    getTree().setRedraw(false);
    // Call the super class so we don't mess up the cache
    super.setCheckedElements(new Object[0]);
    setGrayedElements(new Object[0]);
    // Now we are only going to set the check state of the leaf nodes
    // and rely on our container checked code to update the parents properly.
    Iterator iter = checkState.iterator();
    Object element = null;
    if (iter.hasNext()) expandAll();
    while (iter.hasNext()) {
      element = iter.next();
      // Call the super class as there is no need to update the check state
      super.setChecked(element, true);
    }
    getTree().setRedraw(true);
  }
コード例 #2
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.CheckboxTreeViewer#setCheckedElements(java.lang.Object[])
   */
  public void setCheckedElements(Object[] elements) {
    super.setCheckedElements(elements);
    checkState.clear();

    ITreeContentProvider contentProvider = null;
    if (getContentProvider() instanceof ITreeContentProvider) {
      contentProvider = (ITreeContentProvider) getContentProvider();
    }

    for (int i = 0; i < elements.length; i++) {
      Object[] children = contentProvider != null ? contentProvider.getChildren(elements[i]) : null;
      if (!getGrayed(elements[i]) && (children == null || children.length == 0)) {
        if (!checkState.contains(elements[i])) {
          checkState.add(elements[i]);
        }
      }
    }
  }
コード例 #3
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object)
  */
 public void remove(Object elementsOrTreePaths) {
   updateCheckState(elementsOrTreePaths, false);
   super.remove(elementsOrTreePaths);
 }
コード例 #4
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object[])
  */
 public void remove(Object[] elementsOrTreePaths) {
   for (int i = 0; i < elementsOrTreePaths.length; i++) {
     updateCheckState(elementsOrTreePaths[i], false);
   }
   super.remove(elementsOrTreePaths);
 }