private void populateNetworkTree() {

    DefaultTreeModel tree = (DefaultTreeModel) networkJTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getRoot();
    root.removeAllChildren();
    DefaultMutableTreeNode networkNode;
    DefaultMutableTreeNode stateNode;
    DefaultMutableTreeNode cityNode;
    ArrayList<Network> networkList = system.getNetworkList();
    for (int i = 0; i < networkList.size(); i++) {
      Network country = networkList.get(i);
      networkNode = new DefaultMutableTreeNode(country.getNetworkname());
      root.insert(networkNode, i);
      ArrayList<Network> stateList = country.getSubnetworklist();
      DefaultMutableTreeNode enterpriseNode;
      for (int j = 0; j < stateList.size(); j++) {
        Network state = stateList.get(j);
        stateNode = new DefaultMutableTreeNode(state.getNetworkname());
        networkNode.insert(stateNode, j);
        ArrayList<Network> cityList = state.getSubnetworklist();
        for (int k = 0; k < cityList.size(); k++) {
          Network city = cityList.get(k);
          cityNode = new DefaultMutableTreeNode(city.getNetworkname());
          stateNode.insert(cityNode, k);
        }
      }
    }
    tree.reload();
  }
 private static void addPathToActionsTree(JTree tree, ActionUrl url) {
   final TreePath treePath = CustomizationUtil.getTreePath(tree, url);
   if (treePath == null) return;
   DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
   final int absolutePosition = url.getAbsolutePosition();
   if (node.getChildCount() >= absolutePosition && absolutePosition >= 0) {
     if (url.getComponent() instanceof Group) {
       node.insert(ActionsTreeUtil.createNode((Group) url.getComponent()), absolutePosition);
     } else {
       node.insert(new DefaultMutableTreeNode(url.getComponent()), absolutePosition);
     }
   }
 }
Exemplo n.º 3
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);
      }
    }
  }
  public void populateTree() {

    DefaultTreeModel model = (DefaultTreeModel) JTree.getModel();

    ArrayList<Network> networkList = system.getNetworkList();
    ArrayList<Enterprise> enterpriseList;
    ArrayList<Organization> organizationList;

    Network network;
    Enterprise enterprise;
    Organization organization;

    DefaultMutableTreeNode networks = new DefaultMutableTreeNode("Networks");
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
    root.removeAllChildren();
    root.insert(networks, 0);

    DefaultMutableTreeNode networkNode;
    DefaultMutableTreeNode enterpriseNode;
    DefaultMutableTreeNode organizationNode;

    for (int i = 0; i < networkList.size(); i++) {
      network = networkList.get(i);
      networkNode = new DefaultMutableTreeNode(network.getName());
      networks.insert(networkNode, i);

      enterpriseList = network.getEnterpriseDirectory().getEnterpriseList();

      for (int j = 0; j < enterpriseList.size(); j++) {
        enterprise = enterpriseList.get(j);
        enterpriseNode = new DefaultMutableTreeNode(enterprise.getName());
        networkNode.insert(enterpriseNode, j);

        organizationList = enterprise.getOrganizationDirectory().getOrganizationList();
        for (int k = 0; k < organizationList.size(); k++) {
          organization = organizationList.get(k);
          organizationNode = new DefaultMutableTreeNode(organization.getName());
          enterpriseNode.insert(organizationNode, k);
        }
      }
    }

    model.reload();
  }
Exemplo n.º 5
0
 public static void moveSelectedRow(final JTree tree, final int direction) {
   final TreePath selectionPath = tree.getSelectionPath();
   final DefaultMutableTreeNode treeNode =
       (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
   final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) treeNode.getParent();
   final int idx = parent.getIndex(treeNode);
   parent.remove(treeNode);
   parent.insert(treeNode, idx + direction);
   ((DefaultTreeModel) tree.getModel()).reload(parent);
   selectNode(tree, treeNode);
 }
Exemplo n.º 6
0
  private static void insertNodeAlphabetically(
      DefaultMutableTreeNode parent, DefaultMutableTreeNode newChild) {
    String strNewChild = getDisplayName(newChild);

    int insertAt = 0;
    int parentChildren = parent.getChildCount();
    while (insertAt < parentChildren) {
      String strParentsChild = getDisplayName((DefaultMutableTreeNode) parent.getChildAt(insertAt));
      if (strNewChild.compareToIgnoreCase(strParentsChild) < 0) break;
      ++insertAt;
    }
    parent.insert(newChild, insertAt);
  }
Exemplo n.º 7
0
    /** {@inheritDoc} */
    @Override
    public void insert(final MutableTreeNode aNewChild, final int aChildIndex) {
      super.insert(aNewChild, aChildIndex);

      Object newChildUserObject = ((ElementTreeNode) aNewChild).getUserObject();

      if ((this.userObject instanceof ElementGroup)
          && (newChildUserObject instanceof SignalElement)) {
        // Move the actual element as well...
        ((ElementGroup) this.userObject)
            .moveChannel((SignalElement) newChildUserObject, aChildIndex);
      }
    }
 /**
  * Gets invoked when changes occur to the contents of the list, and updates the nodes of the tree
  * model accordingly. It the invokes <code>reload(node)</code> on the tree model for the affected
  * node so changes are reflected in the <code>JTree</code>
  *
  * @see ca.odell.glazedlists.event.ListEventListener#listChanged
  *     (ca.odell.glazedlists.event.ListEvent)
  */
 public void listChanged(ListEvent listChanges) {
   while (listChanges.next()) {
     int type = listChanges.getType();
     int index = listChanges.getIndex();
     if (type == ListEvent.INSERT) {
       Object element = listChanges.getSourceList().get(index);
       DefaultMutableTreeNode newNode = createChildNode(node, element);
       node.insert(newNode, index);
     } else {
       if (type == ListEvent.UPDATE) {
         node.remove(index);
         Object element = listChanges.getSourceList().get(index);
         DefaultMutableTreeNode newNode = createChildNode(node, element);
         node.insert(newNode, index);
       } else {
         if (type == ListEvent.DELETE) {
           node.remove(index);
         }
       }
     }
   }
   treeModel.reload(node);
 }
Exemplo n.º 9
0
 public void addMessages(AntMessage[] messages) {
   DefaultMutableTreeNode parentNode =
       (DefaultMutableTreeNode) myParentPath.getLastPathComponent();
   int[] indices = new int[messages.length];
   for (int i = 0; i < messages.length; i++) {
     AntMessage message = messages[i];
     MessageNode messageNode = createMessageNode(message);
     indices[i] = parentNode.getChildCount();
     parentNode.insert(messageNode, indices[i]);
     myMessageItems.add(messageNode);
   }
   myTreeModel.nodesWereInserted(parentNode, indices);
   handleExpansion();
 }
  // {{{ restoreFlatNodes() method
  public void restoreFlatNodes(JTree resultTree, DefaultMutableTreeNode operNode) {
    for (int i = 0; i < resultNodes.size(); i++) {
      DefaultMutableTreeNode element = resultNodes.get(i);
      if (element.getUserObject() instanceof HyperSearchFileNode)
        ((HyperSearchFileNode) element.getUserObject()).showFullPath = true;

      operNode.insert(element, operNode.getChildCount());
    }

    ((DefaultTreeModel) resultTree.getModel()).nodeStructureChanged(operNode);

    for (Enumeration e = operNode.children(); e.hasMoreElements(); ) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
      resultTree.expandPath(new TreePath(node.getPath()));
    }
    resultTree.scrollPathToVisible(new TreePath(operNode.getPath()));
  } // }}}
Exemplo n.º 11
0
  private void updateListOfMostRecentAlgorithms() {

    final boolean bShowMostRecent =
        new Boolean(SextanteGUI.getSettingParameterValue(SextanteGeneralSettings.SHOW_MOST_RECENT))
            .booleanValue();
    if (bShowMostRecent) {
      final GeoAlgorithm[] recent = History.getRecentlyUsedAlgs();
      final DefaultMutableTreeNode recentNode =
          new DefaultMutableTreeNode(Sextante.getText("RecentAlgorithms"));
      for (int i = 0; i < recent.length; i++) {
        final DefaultMutableTreeNode node = new DefaultMutableTreeNode(recent[i]);
        recentNode.add(node);
      }
      final DefaultMutableTreeNode mainNode =
          (DefaultMutableTreeNode) new TreePath(jTree.getModel().getRoot()).getLastPathComponent();
      mainNode.remove(0);
      mainNode.insert(recentNode, 0);
    }
  }
Exemplo n.º 12
0
 protected void addNewGroup() {
   final DefaultMutableTreeNode root =
       (DefaultMutableTreeNode)
           ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
   DefaultMutableTreeNode node = root;
   if (node.getChildCount() > 0) {
     node = (DefaultMutableTreeNode) node.getFirstChild();
   }
   if (tree.getSelectionPath() != null) {
     node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
   }
   if (node != root) {
     DefaultMutableTreeNode newNode =
         new ActivableMutableTreeNode(new Group("group" + node.getParent().getChildCount() + 1));
     final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
     parent.insert(newNode, parent.getIndex(node));
     newModel.reload();
     tree.setSelectionPath(new TreePath(newModel.getPathToRoot(newNode)));
   }
 }
 private static void movePathInActionsTree(JTree tree, ActionUrl url) {
   final TreePath treePath = CustomizationUtil.getTreePath(tree, url);
   if (treePath != null) {
     if (treePath.getLastPathComponent() != null) {
       final DefaultMutableTreeNode parent =
           ((DefaultMutableTreeNode) treePath.getLastPathComponent());
       final int absolutePosition = url.getAbsolutePosition();
       final int initialPosition = url.getInitialPosition();
       if (parent.getChildCount() > absolutePosition && absolutePosition >= 0) {
         if (parent.getChildCount() > initialPosition && initialPosition >= 0) {
           final DefaultMutableTreeNode child =
               (DefaultMutableTreeNode) parent.getChildAt(initialPosition);
           if (child.getUserObject().equals(url.getComponent())) {
             parent.remove(child);
             parent.insert(child, absolutePosition);
           }
         }
       }
     }
   }
 }
Exemplo n.º 14
0
  private void addNodeInSortedOrder(
      final DefaultMutableTreeNode parent, final DefaultMutableTreeNode child) {

    final int n = parent.getChildCount();
    if (n == 0) {
      parent.add(child);
      return;
    }
    final Collator collator = Collator.getInstance();
    collator.setStrength(Collator.PRIMARY);
    DefaultMutableTreeNode node = null;
    for (int i = 0; i < n; i++) {
      node = (DefaultMutableTreeNode) parent.getChildAt(i);
      try {
        if (collator.compare(node.toString(), child.toString()) > 0) {
          parent.insert(child, i);
          return;
        }
      } catch (final Exception e) {
      }
    }
    parent.add(child);
  }
Exemplo n.º 15
0
  /**
   * Fills the tree with the algorithms that match a search criteria
   *
   * @param sSearchString The search string to look for in the algorithms context help
   * @param bSearchInFiles true if it should search in help files. if false, it will only search in
   *     algorithm names
   * @return the number of algorithms that match the given criteria
   */
  public int fillTree(final String sSearchString, final boolean bSearchInHelpFiles) {

    m_sLastSearchString = sSearchString;
    m_bLastSearchIncludedHelpFiles = bSearchInHelpFiles;

    int iCount = 0;
    String sGroup, sSubgroup;
    final DefaultMutableTreeNode mainNode =
        new DefaultMutableTreeNode(Sextante.getText("Algorithms"));
    final HashMap<Object, HashMap<String, HashMap<String, DefaultMutableTreeNode>>> groups =
        new HashMap<Object, HashMap<String, HashMap<String, DefaultMutableTreeNode>>>();

    setCursor(new Cursor(Cursor.WAIT_CURSOR));

    // algorithms
    final HashMap<String, HashMap<String, GeoAlgorithm>> algs = Sextante.getAlgorithms();
    final Set<String> groupKeys = algs.keySet();
    final Iterator<String> groupIter = groupKeys.iterator();
    while (groupIter.hasNext()) {
      final String groupKey = groupIter.next();
      final HashMap<String, GeoAlgorithm> groupAlgs = algs.get(groupKey);
      final Set keys = groupAlgs.keySet();
      final Iterator iter = keys.iterator();
      while (iter.hasNext()) {
        final GeoAlgorithm alg = groupAlgs.get(iter.next());
        if (m_Filter.accept(alg)) {
          if (bSearchInHelpFiles) {
            if (!HelpIO.containsStringInHelpFile(alg, sSearchString)) {
              continue;
            }
          } else {
            if ((sSearchString != null) && !alg.getName().toLowerCase().contains(sSearchString)) {
              continue;
            }
          }
          iCount++;
          final AlgorithmGroupConfiguration conf =
              AlgorithmGroupsOrganizer.getGroupConfiguration(alg);
          if (conf != null) {
            if (!conf.isShow()) {
              continue;
            }
            sGroup = conf.getGroup();
            sSubgroup = conf.getSubgroup();
          } else {
            sGroup = groupKey;
            sSubgroup = alg.getGroup();
          }
          HashMap<String, HashMap<String, DefaultMutableTreeNode>> group = groups.get(sGroup);
          if (group == null) {
            group = new HashMap<String, HashMap<String, DefaultMutableTreeNode>>();
            groups.put(sGroup, group);
          }
          HashMap<String, DefaultMutableTreeNode> subgroup = group.get(sSubgroup);
          if (subgroup == null) {
            subgroup = new HashMap<String, DefaultMutableTreeNode>();
            group.put(sSubgroup, subgroup);
          }
          subgroup.put(alg.getName(), new DefaultMutableTreeNode(alg));
        }
      }
    }

    // toolbox actions
    final HashMap<NameAndIcon, ArrayList<ToolboxAction>> allActions =
        SextanteGUI.getToolboxActions();
    final Set<NameAndIcon> actionsKeys = allActions.keySet();
    final Iterator<NameAndIcon> actionsIter = actionsKeys.iterator();
    while (actionsIter.hasNext()) {
      final NameAndIcon nai = actionsIter.next();
      final ArrayList<ToolboxAction> actions = allActions.get(nai);
      for (int i = 0; i < actions.size(); i++) {
        final ToolboxAction ita = actions.get(i);
        if ((sSearchString != null) && !ita.getName().toLowerCase().contains(sSearchString)) {
          continue;
        }
        iCount++;
        sSubgroup = ita.getGroup();
        HashMap<String, HashMap<String, DefaultMutableTreeNode>> group = groups.get(nai.getName());
        if (group == null) {
          group = groups.get(nai);
        }
        if (group == null) {
          group = new HashMap<String, HashMap<String, DefaultMutableTreeNode>>();
          groups.put(nai, group);
        }
        HashMap<String, DefaultMutableTreeNode> subgroup = group.get(sSubgroup);
        if (subgroup == null) {
          subgroup = new HashMap<String, DefaultMutableTreeNode>();
          group.put(sSubgroup, subgroup);
        }
        subgroup.put(ita.getName(), new DefaultMutableTreeNode(ita));
      }
    }

    final Set<Object> set = groups.keySet();
    final Iterator<Object> iter = set.iterator();
    while (iter.hasNext()) {
      final Object key = iter.next();
      final DefaultMutableTreeNode node = new DefaultMutableTreeNode(key);
      addNodeInSortedOrder(mainNode, node);
      final HashMap<String, HashMap<String, DefaultMutableTreeNode>> g = groups.get(key);
      final Set<String> set2 = g.keySet();
      final Iterator<String> iter2 = set2.iterator();
      while (iter2.hasNext()) {
        final String sKey2 = iter2.next();
        final DefaultMutableTreeNode node2 = new DefaultMutableTreeNode(sKey2);
        addNodeInSortedOrder(node, node2);
        final HashMap<String, DefaultMutableTreeNode> g2 = g.get(sKey2);
        final Set<String> set3 = g2.keySet();
        final Iterator<String> iter3 = set3.iterator();
        while (iter3.hasNext()) {
          final String sKey3 = iter3.next();
          final DefaultMutableTreeNode node3 = g2.get(sKey3);
          addNodeInSortedOrder(node2, node3);
        }
      }
    }

    final boolean bShowMostRecent =
        new Boolean(SextanteGUI.getSettingParameterValue(SextanteGeneralSettings.SHOW_MOST_RECENT))
            .booleanValue();
    if (bShowMostRecent) {
      final GeoAlgorithm[] recent = History.getRecentlyUsedAlgs();
      final DefaultMutableTreeNode recentNode =
          new DefaultMutableTreeNode(Sextante.getText("RecentAlgorithms"));
      for (int i = 0; i < recent.length; i++) {
        final DefaultMutableTreeNode node = new DefaultMutableTreeNode(recent[i]);
        recentNode.add(node);
      }
      mainNode.insert(recentNode, 0);
    }

    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

    jTree.setModel(new DefaultTreeModel(mainNode));

    if (sSearchString != null) {
      expandAll();
    }

    m_ParentDialog.setAlgorithmsCount(iCount);

    return iCount;
  }
  // {{{ insertTreeNodes() method
  public void insertTreeNodes(JTree resultTree, DefaultMutableTreeNode operNode) {
    String fileSep = System.getProperty("file.separator");
    String fileSepRegex = System.getProperty("file.separator");
    if (fileSep.equals("\\")) fileSepRegex = "\\\\";

    // find the highest level common path
    String[] topPathTmp = null;
    int topPathNdx = -1;

    for (int i = 0; i < resultNodes.size(); i++) {
      DefaultMutableTreeNode fileTreeNode = resultNodes.get(i);
      Object obj = fileTreeNode.getUserObject();
      if (!(obj instanceof HyperSearchFileNode)) continue;
      HyperSearchFileNode fileNode = (HyperSearchFileNode) obj;

      int pos = fileNode.path.lastIndexOf(fileSep);
      String pathName = fileNode.path.substring(0, pos);
      String[] paths = pathName.split(fileSepRegex);
      if (topPathNdx == -1) {
        topPathNdx = paths.length;
        topPathTmp = paths;
      } else if (paths.length < topPathNdx) {
        topPathNdx = paths.length;
        topPathTmp = paths;
      } else {
        for (int ndx = 0; ndx < topPathNdx; ndx++) {
          if (!paths[ndx].equals(topPathTmp[ndx])) {
            topPathNdx = ndx;
            break;
          }
        }
      }
    }
    String[] topPath = new String[topPathNdx];
    String topPathPath = "";
    for (int ndx = 0; ndx < topPathNdx; ndx++) {
      topPath[ndx] = topPathTmp[ndx];
      topPathPath = topPathPath.concat(topPath[ndx] + fileSep);
    }
    Map<String, DefaultMutableTreeNode> treeNodes = new HashMap<String, DefaultMutableTreeNode>();
    HyperSearchFolderNode folderNode = new HyperSearchFolderNode(new File(topPathPath), true);
    DefaultMutableTreeNode folderTreeNode = new DefaultMutableTreeNode(folderNode);
    operNode.insert(folderTreeNode, operNode.getChildCount());
    treeNodes.put(topPathPath, folderTreeNode);

    for (int i = 0; i < resultNodes.size(); i++) {
      DefaultMutableTreeNode fileTreeNode = resultNodes.get(i);
      Object obj = fileTreeNode.getUserObject();
      if (!(obj instanceof HyperSearchFileNode)) continue;
      HyperSearchFileNode fileNode = (HyperSearchFileNode) obj;

      fileNode.showFullPath = false;
      int pos = fileNode.path.lastIndexOf(fileSep);
      String pathName = fileNode.path.substring(0, pos);
      String[] paths = pathName.split(fileSepRegex);

      DefaultMutableTreeNode insNode = folderTreeNode;
      String partialPath = topPathPath;
      for (int ndx = topPathNdx; ndx < paths.length; ndx++) {
        partialPath = partialPath.concat(paths[ndx] + fileSep);
        DefaultMutableTreeNode tmpNode = treeNodes.get(partialPath);
        if (tmpNode == null) {
          HyperSearchFolderNode tmpFolderNode =
              new HyperSearchFolderNode(new File(partialPath), false);
          tmpNode = new DefaultMutableTreeNode(tmpFolderNode);
          insNode.insert(tmpNode, insNode.getChildCount());
          treeNodes.put(partialPath, tmpNode);
        }
        insNode = tmpNode;
      }
      insNode.insert(fileTreeNode, insNode.getChildCount());
      treeNodes.put(fileNode.path, insNode);
    }
  } // }}}
Exemplo n.º 17
0
  /**
   * Performs a "live-update" to the original DefaultMutableTreeNode by reconsiling the differences
   * between it and a given updated DefaultMutableTreeNode. The resulting original
   * DefaultMutableTreeNode will look identical to the updated node. Appropriate events will fire to
   * keep the GUI consistant with any changes that were made to the model.
   *
   * @param original the model's existing node
   * @param updated the node representing the model node's new state
   */
  private void reconcileNodes(DefaultMutableTreeNode original, DefaultMutableTreeNode updated) {
    SVNTreeNodeData originalData = (SVNTreeNodeData) original.getUserObject();
    SVNTreeNodeData updatedData = (SVNTreeNodeData) updated.getUserObject();
    if (!originalData.equals(updatedData)) {
      originalData.copyNodeValues(updatedData);
    }
    int originalChildCount = original.getChildCount();
    int insertionPoint = 0;

    // loop through the original node's children
    for (int i = insertionPoint; i < originalChildCount; i++) {
      // loop through remaining updated node's children
      boolean found = false;
      DefaultMutableTreeNode originalChildNode =
          (DefaultMutableTreeNode) original.getChildAt(insertionPoint);
      SVNTreeNodeData originalChildData = (SVNTreeNodeData) originalChildNode.getUserObject();
      while (updated.children().hasMoreElements()) {
        DefaultMutableTreeNode updatedChildNode =
            (DefaultMutableTreeNode) updated.children().nextElement();
        SVNTreeNodeData updatedChildData = (SVNTreeNodeData) updatedChildNode.getUserObject();
        if (originalChildData.getPath().equals(updatedChildData.getPath())) {
          // same resource, check equality
          insertionPoint++;
          found = true;
          // remove from updated list so we know we handled this node
          updated.remove(updatedChildNode);
          if (!originalChildData.equals(updatedChildData)) {
            // same resource, different values -- update
            originalChildData.copyNodeValues(updatedChildData);
            reconcileNodes(originalChildNode, updatedChildNode);
            ((DefaultTreeModel) this.getModel()).nodeChanged(originalChildNode);
            break;
          } else {
            // same values, do nothing
            reconcileNodes(originalChildNode, updatedChildNode);
            break;
          }
        } else {
          // different resources
          // does updated node's child need to be inserted before original node's child?
          if (updatedChildData.getPath().compareTo(originalChildData.getPath()) < 0) {
            original.insert(updatedChildNode, insertionPoint);
            ((DefaultTreeModel) this.getModel())
                .nodesWereInserted(original, new int[] {insertionPoint});
            insertionPoint++;
            // inserting the node into the original has the side-effect of removing it from the
            // updated
            // node, just keep going until we've handled all children, or until the remaining
            // children
            // come after the last original node
          } else {
            break;
          }
        }
      }
      if (!found) {
        original.remove(insertionPoint);
        ((DefaultTreeModel) this.getModel())
            .nodesWereRemoved(
                original, new int[] {insertionPoint}, new Object[] {originalChildNode});
      }
    }
    // add any remaining new child nodes
    while (updated.children().hasMoreElements()) {
      DefaultMutableTreeNode updatedChildNode =
          (DefaultMutableTreeNode) updated.children().nextElement();
      original.add(updatedChildNode);
      // adding the new node to the original has the side-effect of removing it from the updated
      // node's children
      // so we just keep going until no children remain
      ((DefaultTreeModel) this.getModel())
          .nodesWereInserted(original, new int[] {insertionPoint++});
    }
  }