Пример #1
0
 public void buttonClicked(ActionEvent e) {
   CustomButtonNode currentButton = (CustomButtonNode) e.getSource();
   if (currentButton.isExpanded()) {
     collapseNode(currentButton);
   } else {
     expandNode(currentButton);
   }
 }
Пример #2
0
  // called when a component is being expanded that has expanded child button nodes
  private void expandChildrenOf(CustomButtonNode button) {
    int index = treeStructure.getChildren().indexOf(button);
    List children = button.getChildren();

    // inserts node items into the appropriate positions in the panelGrid
    // children collection
    for (int a = 0; a < children.size(); a++) {
      treeStructure.getChildren().add(index + 1 + a, (UIComponent) children.get(a));
    }

    // checks every child, if it is a button and its expanded state is set to true,
    // recursively call the method to expand the child node
    for (int a = 0; a < children.size(); a++) {
      Object curChild = children.get(a);
      if (curChild instanceof CustomButtonNode) {
        CustomButtonNode curButton = (CustomButtonNode) curChild;
        if (curButton.isExpanded()) {
          this.expandChildrenOf(curButton);
        }
      }
    }
  }