Пример #1
0
  protected final void loadChildren(DynamicNode node) throws DbException {
    if (node.hasLoaded() || node.isLeaf()) return;
    node.setHasLoaded();
    Object userObject = node.getUserObject();
    if (userObject == ROOT) return;
    SrVector children = new SrVector(10);
    boolean isSorted = true;
    DbObject dbParent = null;
    if (userObject == DB_RAM) {
      Db[] dbs = Db.getDbs();
      for (int i = 0; i < dbs.length; i++) {
        if (dbs[i] instanceof DbRAM) insertProjects(children, dbs[i]);
      }
    } else if (userObject instanceof Db) {
      insertProjects(children, (Db) userObject);
    } else {
      dbParent = (DbObject) userObject;
      dbParent.getDb().beginTrans(Db.READ_TRANS);
      insertComponents(children, dbParent);
      isSorted = childrenAreSorted(dbParent);
      dbParent.getDb().commitTrans();
    }

    if (isSorted) {
      children.sort(getComparator(dbParent));
    }

    ArrayList groupNodeList = new ArrayList();
    DynamicNode groupNode = null;
    Enumeration enumeration = children.elements();
    while (enumeration.hasMoreElements()) {
      DynamicNode childNode = (DynamicNode) enumeration.nextElement();
      GroupParams group = childNode.getGroupParams();
      if (group.name == null) {
        node.add(childNode);
      } else {
        if (groupNode == null) {
          groupNode = createGroupNode(group);
          node.add(groupNode);
          groupNodeList.add(groupNode);
        } else if (!groupNode.toString().equals(group.name)) {
          boolean groupFound = false;
          for (int i = 0; i < groupNodeList.size(); i++) {
            groupNode = (DynamicNode) groupNodeList.get(i);
            if (groupNode.toString().equals(group.name)) {
              groupFound = true;
              break;
            }
          }
          if (!groupFound) {
            groupNode = createGroupNode(group);
            node.add(groupNode);
            groupNodeList.add(groupNode);
          }
        }
        groupNode.add(childNode);
      }
    }
    groupNodeList.clear();
  }
Пример #2
0
 /**
  * If CS application, create a root node with 2 subnodes: RAM and repository; the RAM subnode
  * contains the list of RAM projects as subnodes. If RAM application, create a root node with the
  * list of projects as subnodes.
  */
 private DynamicNode createRootNode() {
   DynamicNode rootNode = null;
   DynamicNode RAMNode = null;
   try {
     RAMNode = new DynamicNode(DB_RAM);
     RAMNode.setDisplayText(DbRAM.DISPLAY_NAME);
     RAMNode.setIcon(kLocalIcon);
     loadChildren(RAMNode);
     Db[] dbs = Db.getDbs();
     for (int i = 0; i < dbs.length; i++) {
       if (dbs[i] instanceof DbRAM) continue;
       if (rootNode == null) {
         rootNode = new DynamicNode(ROOT);
         rootNode.setHasLoaded();
         rootNode.add(RAMNode);
       }
       DynamicNode dbNode = new DynamicNode(dbs[i]);
       dbNode.setDisplayText(dbs[i].getDBMSName());
       dbNode.setIcon(kRepositoryIcon);
       rootNode.add(dbNode);
       loadChildren(dbNode);
     }
   } catch (DbException ex) {
     org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
         ApplicationContext.getDefaultMainFrame(), ex);
   }
   return (rootNode != null ? rootNode : RAMNode);
 }