FileDocCategorySizeDatePackage
TreeNodeFactory.javaAPI DocJBoss 4.2.16007Fri Jul 13 21:02:14 BST 2007org.jboss.console.plugins.helpers

TreeNodeFactory

public class TreeNodeFactory extends Object
see
author
Sacha Labourey.
version
$Revision: 57191 $

Revisions:

31 dec 2002 Sacha Labourey:

  • First implementation

Fields Summary
public static final int
NAME
public static final int
DESCRIPTION
public static final int
ICON_URL
public static final int
DEFAULT_URL
public static final int
MENU_ENTRIES
public static final int
SUB_NODES
public static final int
SUB_RESOURCES
public static final int
MANAGEABLE_RESOURCES
Constructors Summary
Methods Summary
public static org.jboss.console.manager.interfaces.ManageableResourcecreateManageableResource(java.lang.Object content)

      Object[] realContent = (Object[])content;
      return new MBeanResource (new ObjectName((String)realContent[0]), (String)realContent[1]);
   
protected static org.jboss.console.manager.interfaces.TreeNodeMenuEntry[]createTreeMenus(java.lang.Object[] content)

          
      TreeNodeMenuEntry[] menuEntries = null;
      
      if (content != null && content.length > 0)
      {
         menuEntries = new TreeNodeMenuEntry[content.length];
         int i=0;
         while (i< content.length)
         {
            if (content[i] == null)
            {
               menuEntries[i] = new SeparatorTreeNodeMenuEntry();
               i++;
            }
            else
            {
               String text = (String)content[i];
               TreeAction action = new HttpLinkTreeAction((String)content[i+1]);
               menuEntries[i] = new SimpleTreeNodeMenuEntryImpl ( text, action );
               i+=2;
            }
         }         
      }
      else
      {
         menuEntries = new TreeNodeMenuEntry[0];
      }
      return menuEntries;
   
public static org.jboss.console.manager.interfaces.TreeNodecreateTreeNode(java.lang.Object[] content)

   
          
   
      if (content.length != 7 && content.length != 8)
         throw new Exception ("Bad number of parameters");
         
   
      String name = (String)content[NAME];
      String description = (String)content[DESCRIPTION];
      String iconUrl = (String)content[ICON_URL];
      String defaultUrl = (String)content[DEFAULT_URL];
      
      TreeAction action = new HttpLinkTreeAction (defaultUrl);
      
      // menu entries
      //
      TreeNodeMenuEntry[] menuEntries = createTreeMenus ((Object[])content[MENU_ENTRIES]);
      
      // sub nodes
      //
      TreeNode[] subNodes = null;
      Object[] genericSubNodes = (Object[])content[SUB_NODES];
      if (genericSubNodes != null && genericSubNodes.length > 0)
      {
         subNodes = new TreeNode[genericSubNodes.length];
         for (int i=0; i< genericSubNodes.length; i++)
         {
            subNodes[i] = createTreeNode ( (Object[])genericSubNodes[i] );
         }         
      }
      else
      {
         subNodes = new TreeNode[0];
      }
      
      // sub resources nodes
      //
      ResourceTreeNode[] subResNodes = null;
      Object[] genericSubResNodes = (Object[])content[SUB_RESOURCES];
      if (genericSubResNodes != null && genericSubResNodes.length > 0)
      {
         subResNodes = new ResourceTreeNode[genericSubResNodes.length];
         for (int i=0; i< genericSubResNodes.length; i++)
         {
            subResNodes[i] = (ResourceTreeNode)createTreeNode ( (Object[])genericSubResNodes[i] );
         }         
      }
      else
      {
         subResNodes = new ResourceTreeNode[0];
      }                                    
      
      if ((content.length-1) == MANAGEABLE_RESOURCES)
      {
         // we are a resource tree node
         //
         ManageableResource res = createManageableResource (content[MANAGEABLE_RESOURCES]);                  
         return new SimpleResourceTreeNode (name, description, iconUrl, action, menuEntries, subNodes, subResNodes, res);
         
      }
      else
      {
         // we are not a resource tree node, but simply a tree node!
         //
         return new SimpleTreeNode (name, description, iconUrl, action, menuEntries, subNodes, subResNodes);
      }