Adding a Branch to the Enterprise Tree

When Administration Services Console starts, a panel is created called the “Enterprise View”. This panel contains an instance of the CTree class. The text for the root node is called “Enterprise View”. Each plug-in gets the opportunity to add children to the root node. This permits each plug-in to have its own branch in the Enterprise Tree view.

In the plug-in root, add a class called ConsoleTreeHandler. In our example, this would be com.MyPlugin.ConsoleTreeHandler. Add a method called “populateTree()” to this class. The source code should look something like the following example:

public class Console TreeHandler {
  //a no-argument constructor is required by the framework.
  public ConsoleTreeHandler() {
  }
  
  public void populateTree(CTreeModel model) {
    Object root=model.getRoot();
    
    //strictly speaking, this next check should not be
    //necessary; however, we do this to make sure some other
    //plug-in hasn’t replaced the root node with something
    //unexpected.
    if ((root!=null) && (root instanceof CTreeNode))
      //create any CTreeNode-derived objects, adding them
      //as children of the root node.
    }
  }
}

There are some unenforced semantic rules associated with CTree objects: