/**
   * Build the table of plug-in dependencies. Iterate over all the plug-ins in the plug-in registry
   * and the cycle through the list of pre-requisites and create the parent/child relationships in
   * the nodes.
   */
  private Map getDependencyGraph() {
    if (dependencyGraph != null) return dependencyGraph;
    // Build up the dependency graph (see PluginDependencyGraphNode) so
    // we have the information readily available for any plug-in.
    State state = Platform.getPlatformAdmin().getState(false);
    BundleDescription[] plugins = state.getBundles();
    dependencyGraph = new HashMap();
    for (int i = 0; i < plugins.length; i++) {
      BundleDescription descriptor = plugins[i];
      PluginDependencyGraphNode node =
          (PluginDependencyGraphNode) dependencyGraph.get(new Long(descriptor.getBundleId()));
      if (node == null) {
        node = new PluginDependencyGraphNode(descriptor);
        dependencyGraph.put(new Long(descriptor.getBundleId()), node);
      }

      // Cycle through the prerequisites
      BundleSpecification[] requires = descriptor.getRequiredBundles();
      for (int j = 0; j < requires.length; j++) {
        BundleDescription childDesc = (BundleDescription) requires[j].getSupplier();
        // if the child doesn't exist then move to the next child
        if (childDesc == null) continue;

        // if the child entry is not in the table yet then add it
        PluginDependencyGraphNode childNode =
            (PluginDependencyGraphNode) dependencyGraph.get(new Long(childDesc.getBundleId()));
        if (childNode == null) {
          childNode = new PluginDependencyGraphNode(childDesc);
          dependencyGraph.put(new Long(childDesc.getBundleId()), childNode);
        }

        // Add the child to this node's children and set this node as an ancestor
        // of the child node
        node.addChild(childNode);
        childNode.addAncestor(node);
      }
    }
    return dependencyGraph;
  }