TreePath path = hostTree.getSelectionPath(); if (path == null) { System.out.println("CSMARTConsole deleteHostMenuItem called with null path; ignoring"); return;
TreePath[] selectedPaths = hostTree.getSelectionPaths(); for (int i = 0; i < selectedPaths.length; i++) { DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)selectedPaths[i].getLastPathComponent(); ConsoleTreeObject hostCTO = (ConsoleTreeObject)selectedNode.getUserObject();   DefaultTreeModel nodeModel = (DefaultTreeModel)nodeTree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode)nodeModel.getRoot(); int n = selectedNode.getChildCount(); for (int j = 0; j < n; j++) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)selectedNode.getChildAt(0); ConsoleTreeObject cto = (ConsoleTreeObject)node.getUserObject(); if (cto.isNode()) { nodeModel.insertNodeInto(node, root, root.getChildCount()); nodeTree.scrollPathToVisible(new TreePath(node.getPath())); } } DefaultTreeModel hostModel = (DefaultTreeModel)hostTree.getModel(); hostModel.removeNodeFromParent(selectedNode); experiment.removeHost((HostComponent)hostCTO.getComponent());
  public void deleteHostMenuItem_actionPerformed(ActionEvent e) {    TreePath path = hostTree.getSelectionPath();    if (path == null) {      System.out.println("CSMARTConsole deleteHostMenuItem called with null path; ignoring");      return;    }    DefaultMutableTreeNode selectedNode =       (DefaultMutableTreeNode)path.getLastPathComponent();    ConsoleTreeObject hostCTO =       (ConsoleTreeObject)selectedNode.getUserObject();    // get any nodes that are descendants of the host being deleted    // and return them to the unassigned nodes tree    DefaultTreeModel nodeModel = (DefaultTreeModel)nodeTree.getModel();    DefaultMutableTreeNode root =       (DefaultMutableTreeNode)nodeModel.getRoot();    int n = selectedNode.getChildCount();    for (int i = 0; i < n; i++) {      DefaultMutableTreeNode node = 	(DefaultMutableTreeNode)selectedNode.getChildAt(0);      ConsoleTreeObject cto = (ConsoleTreeObject)node.getUserObject();      if (cto.isNode()) {	nodeModel.insertNodeInto(node, root, root.getChildCount());	nodeTree.scrollPathToVisible(new TreePath(node.getPath()));      }    }    DefaultTreeModel hostModel = (DefaultTreeModel)hostTree.getModel();    hostModel.removeNodeFromParent(selectedNode);    experiment.removeHost((HostComponent)hostCTO.getComponent());    //    setRunButtonEnabled();  }