コード例 #1
0
 /**
  * Select/Deselect all children nodes and propagates selection to grand-children nodes.
  *
  * @param abstractNode the abstract node.
  * @param enabled true when the node is checked, false otherwise.
  */
 private void updateEnabledState(@NonNull AbstractNode node, boolean enabled) {
   if (node instanceof ResultValidatableNode) {
     ResultConstrainingNode otherTreeNode =
         ((ResultValidatableNode) node).getResultConstrainingNode();
     otherTreeNode.setEnabled(enabled);
   } else if (node instanceof ResultConstrainingNode) {
     ResultValidatableNode otherTreeNode =
         ((ResultConstrainingNode) node).getResultValidatableNode();
     otherTreeNode.setEnabled(enabled);
   } else {
     for (AbstractNode child : node.getChildren()) {
       node.setEnabled(enabled);
       if (child != null) {
         updateEnabledState(child, enabled);
       }
     }
   }
 }
コード例 #2
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
  */
 public void checkStateChanged(CheckStateChangedEvent event) {
   //		long start = System.currentTimeMillis();
   RootNode rootNode = validityView.getValidityManager().getRootNode();
   assert rootNode != null;
   Object element = event.getElement();
   //		System.out.format(Thread.currentThread().getName() + " %3.3f update start\n",
   // (System.currentTimeMillis() - start) * 0.001);
   if (element instanceof AbstractNode) {
     AbstractNode abstractNode = (AbstractNode) element;
     boolean enabled = event.getChecked();
     abstractNode.setEnabled(enabled);
     /*
      * Propagate the new checked/enabled state of this node to all non-Result children and at the leaves across to the other tree's results.
      */
     updateEnabledState(abstractNode, enabled);
     /*
      * Propgation of the corresponding grayed states up is performed as a total traversal during redraw since this ensures that
      * each node is visited just once, whereas propagating across and up is surprisingly wasteful.
      */
   }
   validityView.redraw();
   //		System.out.format(Thread.currentThread().getName() + " %3.3f redraw end\n",
   // (System.currentTimeMillis() - start) * 0.001);
 }