FileDocCategorySizeDatePackage
StdNodeWrapper.javaAPI DocJBoss 4.2.15968Fri Jul 13 21:02:14 BST 2007org.jboss.console.navtree

StdNodeWrapper

public class StdNodeWrapper extends Object implements NodeWrapper
NodeWrapper implementation for nodes that are not root nodes
see
org.jboss.console.navtree.NodeWrapper
author
Sacha Labourey.
version
$Revision: 57191 $

Revisions:

20 decembre 2002 Sacha Labourey:

  • First implementation

Fields Summary
org.jboss.console.manager.interfaces.TreeNode
node
NodeWrapper[]
sons
org.jboss.console.manager.interfaces.TreeNode[]
realSons
org.jboss.console.manager.interfaces.TreeInfo
master
String
path
Constructors Summary
public StdNodeWrapper(org.jboss.console.manager.interfaces.TreeNode node, org.jboss.console.manager.interfaces.TreeInfo master, String parentPath)

   
   // Static --------------------------------------------------------
   
   // Constructors --------------------------------------------------
   
          
   
      this.node = node;
      this.master = master;
      this.path = parentPath + "/" + this.node.getName ();

      TreeNode[] plugged = null;
      if (node instanceof ResourceTreeNode)
      {
         plugged = master.getTreesForResource( ((ResourceTreeNode)node).getResource() );
         
         // Now we check which kind of visibility we want to give
         //
         int visibility = ((ResourceTreeNode)node).getVisibility();
         if (visibility == ResourceTreeNode.INVISIBLE_IF_SUBNODE_EXISTS &&
             plugged != null && plugged.length > 0)
         {
            this.node = getMasterFromPluggins (plugged);
            plugged = removeMasterFromList (plugged, this.node);
         }
      }
            
      TreeNode[] res = this.node.getNodeManagableResources ();
      TreeNode[] sub = this.node.getSubNodes ();
      
      if (res == null) res = new TreeNode[0];
      if (sub == null) sub = new TreeNode[0];
      if (plugged == null) plugged = new TreeNode[0];

      realSons = new TreeNode[res.length + sub.length + plugged.length];
      sons = new NodeWrapper[res.length + sub.length + plugged.length];

      for (int i=0; i<res.length; i++) 
         realSons[i] = res[i];
      for (int i=0; i<sub.length; i++) 
         realSons[res.length+i] = sub[i];         
      for (int i=0; i<plugged.length; i++) 
         realSons[res.length+sub.length+i] = plugged[i];         
   
Methods Summary
public org.jboss.console.manager.interfaces.TreeActiongetAssociatedAction()

      return this.node.getAction ();
   
public java.lang.ObjectgetChild(int index)

      if (index >= sons.length)
         return null;

      if (sons[index] == null)
         sons[index] = new StdNodeWrapper(realSons[index], this.master, this.path);

      return sons[index];
   
public intgetChildCount()

      return this.realSons.length;
   
public java.lang.StringgetDescription()

      return this.node.getDescription ();
   
public java.lang.StringgetIconUrl()

      return this.node.getIcon ();
   
public intgetIndexOfChild(java.lang.Object child)

      for (int i=0; i<this.sons.length; i++)
      {
         if (this.sons[i] == child)
            return i;
      }
      return -1;         
   
protected org.jboss.console.manager.interfaces.TreeNodegetMasterFromPluggins(org.jboss.console.manager.interfaces.TreeNode[] plugged)

      for (int i=0; i<plugged.length; i++)
      {
         if (plugged[i].isMasterNode())
            return plugged[i];
      }
      
      return plugged[0];
      
   
public org.jboss.console.manager.interfaces.TreeNodeMenuEntry[]getMenuEntries()

      return this.node.getMenuEntries ();
   
public java.lang.StringgetPath()

      return this.path;
   
public booleanisLeaf()

      return this.sons.length == 0;
   
protected org.jboss.console.manager.interfaces.TreeNode[]removeMasterFromList(org.jboss.console.manager.interfaces.TreeNode[] all, org.jboss.console.manager.interfaces.TreeNode main)

      TreeNode[] result = new TreeNode[all.length-1];
      
      int cursor = 0;
      for (int i=0; i<all.length; i++)
      {
         if (all[i] != main)
         {
            result[cursor] = all[i];
            cursor++;
         }
      }
      
      return result;
   
public java.lang.StringtoString()

      return this.node.getName ();