示例#1
0
  /**
   * Busca un nodo dentro del arbol
   *
   * @param raiz Nodo raíz de la consulta
   * @param codigo Código buscado
   * @param nivel Nivel de profundidad del árbol
   * @return Nodo encontrado, null si no lo encuentra
   */
  private DefaultMutableTreeNode buscarNodo(DefaultMutableTreeNode raiz, String codigo, int nivel) {

    DefaultMutableTreeNode nodo = null;

    String auxCodigo = codigoBuscar(codigo, nivel);

    if (raiz != null) {
      if (auxCodigo.compareTo(((UnidadUserObject) raiz.getUserObject()).getUnidad().getCodigo())
          == 0) {
        return raiz;
      } else {
        for (int i = 0; i < raiz.getChildCount(); i++) {
          Unidad comparacion =
              ((UnidadUserObject) ((DefaultMutableTreeNode) raiz.getChildAt(i)).getUserObject())
                  .getUnidad();
          if (auxCodigo.compareTo(comparacion.getCodigo()) == 0) {
            nodo = (DefaultMutableTreeNode) raiz.getChildAt(i);
            break;
          }
        }

        if (nodo != null) {
          return buscarNodo(nodo, codigo, nivel + 1);
        }
      }
    }

    return nodo;
  }
示例#2
0
文件: TreeState.java 项目: jexp/idea2
  private static DefaultMutableTreeNode findMatchedChild(
      DefaultMutableTreeNode parent, PathElement pathElement) {

    for (int j = 0; j < parent.getChildCount(); j++) {
      final TreeNode child = parent.getChildAt(j);
      if (!(child instanceof DefaultMutableTreeNode)) continue;
      final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) child;
      final Object userObject = childNode.getUserObject();
      if (pathElement.matchedWithByObject(userObject)) return childNode;
    }

    for (int j = 0; j < parent.getChildCount(); j++) {
      final TreeNode child = parent.getChildAt(j);
      if (!(child instanceof DefaultMutableTreeNode)) continue;
      final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) child;
      final Object userObject = childNode.getUserObject();
      if (!(userObject instanceof NodeDescriptor)) continue;
      final NodeDescriptor nodeDescriptor = (NodeDescriptor) userObject;
      if (pathElement.matchedWith(nodeDescriptor)) return childNode;
    }

    if (parent.getChildCount() > 0) {
      int index = pathElement.myItemIndex;
      if (index >= parent.getChildCount()) {
        index = parent.getChildCount() - 1;
      }
      final TreeNode child = parent.getChildAt(index);
      if (child instanceof DefaultMutableTreeNode) {
        return (DefaultMutableTreeNode) child;
      }
    }

    return null;
  }
  // ===============================================================
  // ===============================================================
  void putPoolThreadInfo() {
    //  ToDo
    //	Get configuration from tree
    int nbThreads = root.getChildCount();
    ArrayList<String> lines = new ArrayList<String>();
    for (int i = 0; i < root.getChildCount(); i++) {
      DefaultMutableTreeNode threadNode = (DefaultMutableTreeNode) root.getChildAt(i);
      int deviceNumber = threadNode.getChildCount();
      if (deviceNumber > 0) {
        String s = "";
        for (int j = 0; j < deviceNumber; j++) {
          s += threadNode.getChildAt(j).toString();
          if (j < deviceNumber - 1) s += ",";
        }
        lines.add(s);
      }
    }
    //  Check for maximum length of lines
    lines = manageMaxLength(lines);

    //	Convert tree to device(admin) property.
    String[] config = new String[lines.size()];
    for (int i = 0; i < lines.size(); i++) config[i] = lines.get(i);

    //	And send it to database.
    try {
      DbDatum[] argin = new DbDatum[2];
      argin[0] = new DbDatum(propertyNames[NB_THREADS], nbThreads);
      argin[1] = new DbDatum(propertyNames[THREADS_CONFIG], config);
      server.put_property(argin);
    } catch (DevFailed e) {
      ErrorPane.showErrorMessage(parent, null, e);
    }
  }
 // ===============================================================
 // ===============================================================
 private DefaultMutableTreeNode getFutureSelectedNode(DefaultMutableTreeNode node) {
   //	Get the future selectd node, after remove.
   DefaultMutableTreeNode parent_node = (DefaultMutableTreeNode) node.getParent();
   DefaultMutableTreeNode ret_node = parent_node;
   for (int i = 0; i < parent_node.getChildCount(); i++) {
     DefaultMutableTreeNode child_node = (DefaultMutableTreeNode) parent_node.getChildAt(i);
     if (child_node == node) {
       if (i == parent_node.getChildCount() - 1) {
         if (i > 0) ret_node = (DefaultMutableTreeNode) parent_node.getChildAt(i - 1);
       } else ret_node = (DefaultMutableTreeNode) parent_node.getChildAt(i + 1);
     }
   }
   return ret_node;
 }
示例#5
0
  public void viderNoeud(DefaultMutableTreeNode selectednode) {
    int nbchildren = selectednode.getChildCount();

    for (int i = 0; i < nbchildren; i++) {
      if (selectednode.getChildAt(0).isLeaf()) {
        ((DefaultMutableTreeNode) selectednode.getChildAt(0)).removeFromParent();
      } else {
        viderNoeud((DefaultMutableTreeNode) selectednode.getChildAt(0));
      }
    }
    if (!selectednode.isRoot()) {
      selectednode.removeFromParent();
    }
  }
示例#6
0
  public synchronized void setRooms(Room[] room) {
    if (room == null) {
      room = new Room[0];
    }

    // Remove rooms no longer present
    for (int i = 0; i < root.getChildCount(); ++i) {
      Room r = roomAt(i);
      int j = 0;
      for (j = 0; j < room.length; ++j) {
        if (room[j] == r) {
          break;
        } else if (room[j].equals(r)) {
          model.valueForPathChanged(
              new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()), room[j]);
          break;
        }
      }
      if (j >= room.length) { // No match
        model.removeNodeFromParent((DefaultMutableTreeNode) root.getChildAt(i--));
      }
    }
    // Add new rooms
    for (int i = 0; i < room.length; ++i) {
      int j;
      for (j = 0; j < root.getChildCount(); ++j) {
        if (roomAt(j) == room[i]) {
          break;
        }
      }
      if (j >= root.getChildCount()) {
        model.insertNodeInto(new DefaultMutableTreeNode(room[i]), root, i);
      }
    }
    // Update players
    for (int i = 0; i < root.getChildCount(); ++i) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
      List<Player> p = roomAt(i).getPlayerList();
      while (p.size() < node.getChildCount()) {
        model.removeNodeFromParent((DefaultMutableTreeNode) node.getChildAt(0));
      }
      while (p.size() > node.getChildCount()) {
        model.insertNodeInto(new DefaultMutableTreeNode(room[i]), node, 0);
      }
      for (int j = 0; j < node.getChildCount(); ++j) {
        model.valueForPathChanged(
            new TreePath(((DefaultMutableTreeNode) node.getChildAt(j)).getPath()), p.get(j));
      }
    }
  }
示例#7
0
文件: TreeView.java 项目: jexp/idea2
 private void collapseTargets() {
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTreeModel.getRoot();
   for (int i = 0; i < root.getChildCount(); i++) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
     myTree.collapsePath(new TreePath(node.getPath()));
   }
 }
示例#8
0
文件: TreeView.java 项目: jexp/idea2
  public boolean restoreSelection(TreeSelection treeSelection) {
    if (treeSelection.isEmpty()) return false;

    DefaultMutableTreeNode root = (DefaultMutableTreeNode) myTreeModel.getRoot();
    for (int i = 0; i < root.getChildCount(); i++) {
      TreeNode node = root.getChildAt(i);
      if (node instanceof MessageNode) {
        MessageNode messageNode = (MessageNode) node;
        String[] text = messageNode.getText();
        if (text.length == 0) continue;
        if (Comparing.equal(treeSelection.mySelectedTarget, text[0])) {
          TreePath pathToSelect = new TreePath(messageNode.getPath());
          for (Enumeration enumeration = messageNode.children(); enumeration.hasMoreElements(); ) {
            Object o = enumeration.nextElement();
            if (o instanceof MessageNode) {
              messageNode = (MessageNode) o;
              if (Comparing.equal(treeSelection.mySelectedTask, text[0])) {
                pathToSelect = new TreePath(messageNode.getPath());
                break;
              }
            }
          }
          TreeUtil.selectPath(myTree, pathToSelect);
          myTree.expandPath(pathToSelect);
          return true;
        }
      }
    }

    return false;
  }
示例#9
0
  /**
   * Gets the insert position for newGeo to insert it in alphabetical order in parent node. Note:
   * all children of parent must have instances of GeoElement as user objects.
   *
   * @param mode
   */
  public static final int getInsertPosition(
      DefaultMutableTreeNode parent, GeoElement newGeo, SortMode mode) {
    // label of inserted geo
    // String newLabel = newGeo.getLabel();

    // standard case: binary search
    int left = 0;
    int right = parent.getChildCount();
    if (right == 0) return right;

    // bigger then last?
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent.getLastChild();
    // String nodeLabel = ((GeoElement) node.getUserObject()).getLabel();
    GeoElement geo2 = ((GeoElement) node.getUserObject());
    if (compare(newGeo, geo2, mode)) return right;

    // binary search
    while (right > left) {
      int middle = (left + right) / 2;
      node = (DefaultMutableTreeNode) parent.getChildAt(middle);
      // nodeLabel = ((GeoElement) node.getUserObject()).getLabel();
      geo2 = ((GeoElement) node.getUserObject());

      if (!compare(newGeo, geo2, mode)) {
        right = middle;
      } else {
        left = middle + 1;
      }
    }

    // insert at correct position
    return right;
  }
  private DefaultMutableTreeNode addParamNode(String[] paramSeq) {
    String param = null;
    DefaultMutableTreeNode parent = getRootNode();
    DefaultMutableTreeNode child = null;
    DefaultMutableTreeNode result = null;

    for (int i = 0; i < paramSeq.length; i++) {
      param = paramSeq[i];
      result = null;
      for (int j = 0; j < parent.getChildCount(); j++) {
        child = (DefaultMutableTreeNode) parent.getChildAt(j);
        if (child.toString().equalsIgnoreCase(param)) {
          result = child;
          break;
        }
      }

      if (result == null) {
        result = new DefaultMutableTreeNode(param);
        parent.add(result);
      }

      parent = result;
    }

    return parent;
  }
示例#11
0
    /**
     * This gets called whenever one of the ConfigElements we are editing removes a property value.
     */
    public void propertyValueRemoved(ConfigElementEvent evt) {
      ConfigElement src = (ConfigElement) evt.getSource();
      int idx = evt.getIndex();
      PropertyDefinition prop_def = src.getDefinition().getPropertyDefinition(evt.getProperty());
      DefaultMutableTreeNode elt_node = getNodeFor(src);

      // Get the node containing the property description under the source
      // ConfigElement node
      for (Enumeration e = elt_node.children(); e.hasMoreElements(); ) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        if (node.getUserObject().equals(prop_def)) {
          // The newly removed property value must be a child to this node
          System.out.println("Removing child " + idx + " from node: " + node.getUserObject());
          DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(idx);

          // If the child is an embedded element, stop listening to it
          if (child.getUserObject() instanceof ConfigElement) {
            ConfigElement removed_elt = (ConfigElement) child.getUserObject();
            removed_elt.removeConfigElementListener(this);
          }

          // Physically remove the child from the tree
          removeNodeFromParent(child);
        }
      }
    }
示例#12
0
 private ArrayList<TreeNode> childrenToArray(DefaultMutableTreeNode node) {
   ArrayList<TreeNode> arrayList = new ArrayList<TreeNode>();
   for (int i = 0; i < node.getChildCount(); i++) {
     arrayList.add(node.getChildAt(i));
   }
   return arrayList;
 }
示例#13
0
  /**
   * 参数条件树上增加节点
   *
   * @param conditionNodeObj
   */
  private TreeNode addParaTreNode(IStatisticCaliber aCal) {
    // 得到父节点
    DefaultTreeModel treeModel = (DefaultTreeModel) treWhere.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
    // 判断增加的父节点是否已存在,默认父节点不存在
    boolean sFlag = false;
    IStatisticCaliber curCal = null;
    DefaultMutableTreeNode curNode = null;
    int iChildCount = root.getChildCount();
    // 得到根节点下的子节点
    for (int i = 0; i < iChildCount; i++) {
      curNode = (DefaultMutableTreeNode) root.getChildAt(i);
      curCal = ((Caliber) curNode.getUserObject()).getACal();
      if (aCal.getSourceID().equals(curCal.getSourceID())) {
        sFlag = true;
        break;
      }
    }

    DefaultMutableTreeNode ANode = null;
    if (!sFlag) { // 父节点不存在
      // 增加父节点
      ICustomStatisticCaliber parCal = new MySummaryStatisticCaliberImpl();
      parCal.setSourceID(aCal.getSourceID());
      // 数据源名称
      String sDataSourceName = dataSourceCbx.getRefModel().getNameByValue(aCal.getSourceID());
      parCal.setValue(sDataSourceName);
      ANode = new DefaultMutableTreeNode(new Caliber(parCal));
      treeModel.insertNodeInto(ANode, root, root.getChildCount());
      curNode = (DefaultMutableTreeNode) root.getLastChild();
    }
    ANode = new DefaultMutableTreeNode(new Caliber(aCal));
    treeModel.insertNodeInto(ANode, curNode, curNode.getChildCount());
    return ANode;
  }
示例#14
0
  private void buildTreeFromString(DefaultTreeModel model, final String str) {
    // Fetch the root node
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();

    // Split the string around the delimiter
    String[] strings = str.split("/");

    // Create a node object to use for traversing down the tree as it
    // is being created
    DefaultMutableTreeNode node = root;
    // Iterate of the string array
    for (String s : strings) {
      // Look for the index of a node at the current level that
      // has a value equal to the current string
      int index = childIndex(node, s);

      // Index less than 0, this is a new node not currently present on
      // the tree
      if (index < 0) {
        // Add the new node
        DefaultMutableTreeNode newChild = new DefaultMutableTreeNode(s);
        node.insert(newChild, node.getChildCount());
        node = newChild;
      }
      // Else, existing node, skip to the next string
      else {
        node = (DefaultMutableTreeNode) node.getChildAt(index);
      }
    }
  }
 /** Expand the current node and return the list of leaves (MaterialVO objects). */
 private ArrayList getComponents(DefaultMutableTreeNode node) {
   ArrayList list = new ArrayList();
   for (int i = 0; i < node.getChildCount(); i++)
     list.addAll(getComponents((DefaultMutableTreeNode) node.getChildAt(i)));
   if (node.isLeaf()) list.add(node.getUserObject());
   return list;
 }
示例#16
0
  private ArrayList<?> updateSelectedGeos(TreePath[] selPath) {
    selectionList.clear();

    if (selPath != null) {
      // add all selected paths
      for (int i = 0; i < selPath.length; i++) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath[i].getLastPathComponent();

        if (node == node.getRoot()) {
          // root: add all objects
          selectionList.clear();
          selectionList.addAll(app.getKernel().getConstruction().getGeoSetLabelOrder());
          i = selPath.length;
        } else if (node.getParent() == node.getRoot()) {
          // type node: select all children
          for (int k = 0; k < node.getChildCount(); k++) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(k);
            selectionList.add(child.getUserObject());
          }
        } else {
          // GeoElement
          selectionList.add(node.getUserObject());
        }
      }
    }

    return selectionList;
  }
  public void setWsdlModel(WSDLModel wsdlModel) {
    if (this.wsdlModel == wsdlModel) {
      return;
    }

    this.wsdlModel = wsdlModel;
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    for (Port port : Util.getSortedPorts(wsdlModel)) {
      Binding binding = port.getBinding().get();
      List<BindingOperation> bindingOps = Util.getSortedBindingOperations(binding);
      if (bindingOps != null && bindingOps.size() > 0) {
        DefaultMutableTreeNode portNode = new DefaultMutableTreeNode(port);
        root.add(portNode);
        for (BindingOperation bindingOp : bindingOps) {
          DefaultMutableTreeNode bindingOpNode = new DefaultMutableTreeNode(bindingOp);
          portNode.add(bindingOpNode);
          bindingOpNode.setAllowsChildren(false);
        }
      }
    }
    DefaultTreeModel dtm = new DefaultTreeModel(root);
    mTree.setModel(dtm);
    int cnt = root.getChildCount();
    for (int i = 0; i < cnt; i++) {
      mTree.expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
    }
  }
  public void updateClientState(Node nodeUpdate) {
    for (int i = 0; i < rootNode.getChildCount(); i++) {
      TreeNode treeNode = rootNode.getChildAt(i);
      //            System.out.println(treeNode.toString());
      if (treeNode.toString().equals(nodeUpdate.getName())) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode;
        if (nodeUpdate.isOnline() && nodeUpdate.isValid()) {
          // 删除”状态:在线,可信“ 那一行
          node.remove(2);

          node.add(new DefaultMutableTreeNode("状态:在线,可信"));
          Log.i(this.getClass().getName(), nodeUpdate.getName() + " 已登录,状态可信.");

        } else if (nodeUpdate.isOnline() && !nodeUpdate.isValid()) {
          node.remove(2);
          node.add(new DefaultMutableTreeNode("状态:在线,不可信"));
          Log.v(
              this.getClass().getName(),
              nodeUpdate.getName() + "状态不可信,IP地址为:" + nodeUpdate.getIP());
        } else {
          node.remove(2);
          node.add(new DefaultMutableTreeNode("状态:离线"));
          Log.i(
              this.getClass().getName(), nodeUpdate.getName() + "不在线,IP地址为:" + nodeUpdate.getIP());
        }
        this.jTree.updateUI();
        return;
      }
    }
  }
  public DefaultMutableTreeNode findNode(
      DefaultMutableTreeNode rootNode, IFoundSet foundSet, int recordIndex) {

    int childCount = 0;

    if (rootNode instanceof UserNode) {
      childCount = ((UserNode) rootNode).getCurrentChildCount();

      UserNode userNode = (UserNode) rootNode;

      if (userNode.getFoundSet().equals(foundSet) && userNode.getRecordIndex() == recordIndex) {
        return userNode;
      }
    } else {
      childCount = rootNode.getChildCount();
    }

    if (childCount > 0) {
      DefaultMutableTreeNode childNode, foundNode;

      for (int i = 0; i < childCount; i++) {
        childNode = (DefaultMutableTreeNode) rootNode.getChildAt(i);
        foundNode = findNode(childNode, foundSet, recordIndex);
        if (foundNode != null) {
          return foundNode;
        }
      }
    }

    return null;
  }
示例#20
0
  private void expandEntireTree(DefaultMutableTreeNode tNode) {
    TreePath tp = new TreePath(((DefaultMutableTreeNode) tNode).getPath());
    detailsTree.expandPath(tp);

    for (int i = 0; i < tNode.getChildCount(); i++) {
      expandEntireTree((DefaultMutableTreeNode) tNode.getChildAt(i));
    }
  }
示例#21
0
 /** This gets called whenever one of the ConfigElements we are modeling has changed its name. */
 public void nameChanged(ConfigElementEvent evt) {
   ConfigElement src = (ConfigElement) evt.getSource();
   DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
   DefaultMutableTreeNode name_node = (DefaultMutableTreeNode) root.getChildAt(0);
   name_node.setUserObject(src.getName());
   fireTreeNodesChanged(
       this, new Object[] {getPathToRoot(root)}, new int[] {0}, new Object[] {name_node});
 }
 // ===============================================================
 // ===============================================================
 private int getNextThreadNum() {
   int num = 0;
   for (int i = 0; i < root.getChildCount(); i++) {
     DefaultMutableTreeNode th_node = (DefaultMutableTreeNode) root.getChildAt(i);
     num = ((PollThread) th_node.getUserObject()).num;
   }
   return ++num;
 }
示例#23
0
 /**
  * Performs a linear search for geo among the children of parent.
  *
  * @return -1 when not found
  */
 public static final int linearSearchGeo(DefaultMutableTreeNode parent, String geoLabel) {
   int childCount = parent.getChildCount();
   for (int i = 0; i < childCount; i++) {
     DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent.getChildAt(i);
     GeoElement g = (GeoElement) node.getUserObject();
     if (geoLabel.equals(g.getLabel())) return i;
   }
   return -1;
 }
  private String stringifyResult(DefaultMutableTreeNode selectedResultNode) {
    List<Object> stringifiedObjects = new LinkedList<Object>();
    for (int i = 0; i < selectedResultNode.getChildCount(); i++) {
      DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) selectedResultNode.getChildAt(i);
      stringifiedObjects.add(childNode.getUserObject());
    }

    return String.format("[ %s ]", StringUtils.join(stringifiedObjects, " , "));
  }
示例#25
0
文件: TreeUtil.java 项目: jexp/idea2
 public static void sort(final DefaultMutableTreeNode node, final Comparator comparator) {
   final List<TreeNode> children = childrenToArray(node);
   Collections.sort(children, comparator);
   node.removeAllChildren();
   addChildrenTo(node, children);
   for (int i = 0; i < node.getChildCount(); i++) {
     sort((DefaultMutableTreeNode) node.getChildAt(i), comparator);
   }
 }
 private static DefaultMutableTreeNode findInChildren(
     DefaultMutableTreeNode currentTreeNode, AbstractTreeNode topPathElement) {
   for (int i = 0; i < currentTreeNode.getChildCount(); i++) {
     TreeNode child = currentTreeNode.getChildAt(i);
     if (((DefaultMutableTreeNode) child).getUserObject().equals(topPathElement)) {
       return (DefaultMutableTreeNode) child;
     }
   }
   return null;
 }
示例#27
0
    /**
     * Returns the tree path of geo
     *
     * @return returns null if geo is not in tree
     */
    private TreePath getTreePath(GeoElement geo) {
      DefaultMutableTreeNode typeNode = typeNodesMap.get(geo.getObjectType());
      if (typeNode == null) return null;

      // find pos of geo
      int pos = AlgebraView.binarySearchGeo(typeNode, geo.getLabel());
      if (pos == -1) return null;

      return new TreePath(((DefaultMutableTreeNode) typeNode.getChildAt(pos)).getPath());
    }
示例#28
0
    public void treeNodesChanged(TreeModelEvent e) {
      DefaultMutableTreeNode node;
      node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent());

      int index = e.getChildIndices()[0];
      node = (DefaultMutableTreeNode) (node.getChildAt(index));

      System.out.println("The user has finished editing the node.");
      System.out.println("New value: " + node.getUserObject());
    }
示例#29
0
 private synchronized void filterNode(
     DefaultMutableTreeNode node, String text, DefaultMutableTreeNode filtered) {
   for (int i = 0; i < node.getChildCount(); i++) {
     DefaultMutableTreeNode nameNode = (DefaultMutableTreeNode) node.getChildAt(i);
     String name = (String) nameNode.getUserObject();
     if (name.startsWith(text)) {
       filtered.add(new DefaultMutableTreeNode(name));
     }
   }
 }
示例#30
0
  private void remove(Object obj, DefaultMutableTreeNode parent) {
    for (int i = 0; i < parent.getChildCount(); i++) {
      if (!(parent.getChildAt(i) instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) parent.getChildAt(i);

      if (!node.isLeaf()) remove(obj, node);
      else if (node.isLeaf()) {
        if (node.getUserObject().equals(obj)) {
          parent.remove(node);
          if (parent.getChildCount() == 0 && parent.getParent() instanceof DefaultMutableTreeNode) {
            ((DefaultMutableTreeNode) parent.getParent()).remove(parent);
          }

          treeModel.nodeStructureChanged(root);
          expandAllTree();
          return;
        }
      }
    }
  }