1 22 package org.jboss.console.navtree; 23 24 import java.util.Vector ; 25 26 import org.jboss.console.manager.interfaces.ManageableResource; 27 import org.jboss.console.manager.interfaces.TreeAction; 28 import org.jboss.console.manager.interfaces.TreeInfo; 29 import org.jboss.console.manager.interfaces.TreeNode; 30 import org.jboss.console.manager.interfaces.TreeNodeMenuEntry; 31 32 48 49 public class RootWrapper 50 implements NodeWrapper 51 { 52 54 56 TreeInfo tree = null; 57 58 NodeWrapper[] sons = null; 59 TreeNode[] realSons = null; 60 61 63 65 public RootWrapper (TreeInfo tree) 66 { 67 this.tree = tree; 68 69 Vector nodes = new Vector (); 72 ManageableResource[] roots = tree.getRootResources (); 73 for (int i=0; i<roots.length; i++) 74 { 75 ManageableResource mr = roots[i]; 76 TreeNode[] ns = tree.getTreesForResource (mr); 77 if (ns != null && ns.length > 0) 78 nodes.addAll (java.util.Arrays.asList (ns)); 79 } 80 81 realSons = new TreeNode[nodes.size ()]; 82 sons = new NodeWrapper[nodes.size ()]; 83 84 for (int i=0; i<realSons.length; i++) 85 realSons[i] = (TreeNode)nodes.elementAt (i); 86 87 } 88 89 91 93 public Object getChild (int index) 94 { 95 if (index >= sons.length) 96 return null; 97 98 if (sons[index] == null) 99 sons[index] = new StdNodeWrapper(realSons[index], tree, ""); 100 101 return sons[index]; 102 } 103 104 public int getChildCount () 105 { 106 return this.realSons.length; 107 } 108 109 public int getIndexOfChild (Object child) 110 { 111 for (int i=0; i<this.sons.length; i++) 112 { 113 if (this.sons[i] == child) 114 return i; 115 } 116 return -1; 117 } 118 119 public boolean isLeaf () 120 { 121 return this.sons.length == 0; 122 } 123 124 public String getIconUrl () 125 { 126 return this.tree.getIconUrl(); 127 } 128 129 public String toString () 130 { 131 return "JBoss Management Console"; 132 } 133 134 public TreeAction getAssociatedAction () 135 { 136 return this.tree.getHomeAction (); 137 } 138 139 public String getDescription () 140 { 141 return this.tree.getDescription (); 142 } 143 144 public TreeNodeMenuEntry[] getMenuEntries () 145 { 146 return this.tree.getRootMenus(); 147 } 148 149 public String getPath () 150 { 151 return ""; 152 } 153 155 157 159 161 163 } 164 165 | Popular Tags |