private void insertProjects(SrVector children, Db db) throws DbException {
   db.beginTrans(Db.READ_TRANS);
   DbObject parent = db.getRoot();
   DbEnumeration dbEnum = parent.getComponents().elements(DbProject.metaClass);
   while (dbEnum.hasMoreElements())
     children.addElement(createPrimaryNode(parent, dbEnum.nextElement()));
   dbEnum.close();
   db.commitTrans();
 }
  // Overridden
  protected void insertComponents(SrVector children, DbObject dbParent) throws DbException {
    SemanticalModel model = ApplicationContext.getSemanticalModel();

    DbEnumeration dbEnum = dbParent.getComponents().elements();
    while (dbEnum.hasMoreElements()) {
      DbObject dbo = dbEnum.nextElement();
      boolean isVisible = model.isVisibleOnScreen(dbParent, dbo, Explorer.class);
      if (isVisible) {
        children.addElement(createPrimaryNode(dbParent, dbo));
      } // end if
    } // end while
    dbEnum.close();
  } // end insertComponents()
  protected final void refresh(DynamicNode parentNode) throws DbException {
    if (ApplicationContext.getFocusManager().isGuiLocked()) return;

    if (parentNode == null) return;
    if (!parentNode.hasLoaded() || parentNode.isLeaf()) {
      if (parentNode.getUserObject() instanceof DbObject)
        updateNode((DbObject) parentNode.getUserObject());
      return;
    }
    Object userObject = parentNode.getUserObject();
    if (userObject == ROOT) {
      int count = getChildCount(parentNode);
      for (int i = 0; i < count; i++) {
        DynamicNode node = (DynamicNode) getChild(parentNode, i);
        userObject = node.getUserObject();
        if (userObject == DB_RAM) refresh(node);
        else {
          if (((Db) userObject).isValid()) {
            ((Db) userObject).beginTrans(Db.READ_TRANS);
            refresh(node);
            ((Db) userObject).commitTrans();
          } else {
            removeNode(node);
          }
        }
      }
      return;
    }
    if (userObject == DB_RAM) {
      int count = getChildCount(parentNode);
      for (int i = count - 1; i >= 0; i--) {
        DynamicNode node = (DynamicNode) getChild(parentNode, i);
        Db db = ((DbObject) node.getUserObject()).getDb();
        if (!db.isValid()) {
          removeNode(node);
          continue;
        }
        db.beginTrans(Db.READ_TRANS);
        refresh(node);
        // refresh the display text for the projects - we do not want to
        // apply a full update
        // using update(dbo) because we want to preserve the expanded
        // state for projects.
        node.setDisplayText(getDisplayText(null, (DbObject) node.getUserObject()));
        db.commitTrans();
      }
      // check for missing Db
      Db[] dbs = Db.getDbs();
      for (int i = 0; i < dbs.length; i++) {
        if (!dbs[i].isValid() || !(dbs[i] instanceof DbRAM)) continue;
        DynamicNode dbNode = getDynamicNode(parentNode, dbs[i], 0);
        if (dbNode != null) continue;
        dbs[i].beginTrans(Db.READ_TRANS);
        DbEnumeration dbEnum = dbs[i].getRoot().getComponents().elements(DbProject.metaClass);
        if (dbEnum.hasMoreElements()) {
          getDynamicNode(dbEnum.nextElement(), false);
        }
        dbEnum.close();
        dbs[i].commitTrans();
      }
      return;
    }

    SrVector children = new SrVector(10);
    if (userObject instanceof Db) {
      insertProjects(children, (Db) userObject);
      children.sort();
    } else if (((DbObject) userObject).isAlive()) {
      insertComponents(children, (DbObject) userObject);
      if (childrenAreSorted((DbObject) userObject))
        children.sort(getComparator((DbObject) userObject));
    }

    DynamicNode groupNode = null;
    int index = 0;
    int iGroup = 0;
    for (int i = 0; i < children.size(); i++) {
      DynamicNode srcNode = (DynamicNode) children.elementAt(i);
      GroupParams group = srcNode.getGroupParams();
      if (group.name == null) {
        refreshNode(srcNode, parentNode, index);
        index++;
      } else {
        if (groupNode == null || !groupNode.toString().equals(group.name)) {
          if (groupNode != null) deleteNodes(groupNode, iGroup);
          groupNode = getGroupNode(parentNode, group, index);
          if (groupNode == null) {
            groupNode = createGroupNode(group);
            insertNodeInto(groupNode, parentNode, index);
          } else if (groupNode != getChild(parentNode, index)) {
            removeNodeFromParent(groupNode);
            insertNodeInto(groupNode, parentNode, index);
          }
          index++;
          iGroup = 0;
        }
        refreshNode(srcNode, groupNode, iGroup);
        iGroup++;
      }
    }
    if (groupNode != null) deleteNodes(groupNode, iGroup);
    deleteNodes(parentNode, index);

    // Refresh subnodes in a separate pass to avoid interference from
    // automatic
    // adding of a primary node when adding a secondary node.
    refreshChildren(parentNode);
  }