1 22 package org.jboss.console.manager.interfaces.impl; 23 24 import org.jboss.console.manager.interfaces.ManageableResource; 25 import org.jboss.console.manager.interfaces.TreeAction; 26 import org.jboss.console.manager.interfaces.TreeInfo; 27 import org.jboss.console.manager.interfaces.TreeNode; 28 import org.jboss.console.manager.interfaces.TreeNodeMenuEntry; 29 30 import java.util.ArrayList ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 34 49 50 public class DefaultTreeInfo 51 implements TreeInfo 52 { 53 54 56 58 protected ManageableResource[] roots = null; 59 protected HashMap resources = new HashMap (); 60 protected TreeAction homeAction = null; 61 protected String jbossVersion = null; 62 protected long version = 0; 63 protected TreeNodeMenuEntry[] rootMenus = new TreeNodeMenuEntry[0]; 64 protected String iconUrl = null; 65 66 68 70 public DefaultTreeInfo () 71 { 72 Package jbossPackage = Package.getPackage("org.jboss"); 73 jbossVersion = jbossPackage.getImplementationTitle() + " " + 74 jbossPackage.getImplementationVersion(); 75 76 } 77 78 80 public ManageableResource[] getRootResources () 81 { 82 return this.roots; 83 } 84 85 public void setRootResources (ManageableResource[] roots) 86 { 87 this.roots = roots; 88 } 89 90 public synchronized TreeNode[] getTreesForResource (ManageableResource resource) 91 { 92 ArrayList content = (ArrayList )resources.get (resource); 93 if (content == null || content.size () == 0) 94 return null; 95 else 96 { 97 TreeNode[] result = new TreeNode[content.size ()]; 98 return (TreeNode[])content.toArray (result); 99 } 100 } 101 102 public synchronized void addTreeToResource (ManageableResource resource, TreeNode tree) 103 { 104 ArrayList content = (ArrayList )resources.get (resource); 105 if (content == null || content.size () == 0) 106 { 107 content = new ArrayList (); 108 resources.put (resource, content); 109 } 110 111 if (!content.contains (tree)) 112 content.add (tree); 113 } 114 115 public TreeAction getHomeAction () 116 { 117 return this.homeAction; 118 } 119 120 public void setHomeAction (TreeAction homeAction) 121 { 122 this.homeAction = homeAction; 123 } 124 125 public String getDescription () 126 { 127 return jbossVersion; 128 } 129 130 public void setRootMenus (TreeNodeMenuEntry[] menus) 131 { 132 this.rootMenus = menus; 133 } 134 135 public TreeNodeMenuEntry[] getRootMenus () 136 { 137 return this.rootMenus; 138 } 139 140 142 144 public String toString () 145 { 146 String result = "Root: " + roots + "\n" ; 147 148 Iterator iter = resources.keySet ().iterator (); 149 while (iter.hasNext ()) 150 { 151 ManageableResource key = (ManageableResource)iter.next(); 152 ArrayList content = (ArrayList )resources.get (key); 153 154 result+=" Key: " + key + "\n"; 155 156 for (int i = 0; i < content.size(); i++) 157 { 158 result += " Value: " + content.get(i); 159 } 160 161 result+=" ----\n"; 162 163 } 164 return result; 165 } 166 167 public long getTreeVersion () 168 { 169 return this.version; 170 } 171 172 public void setTreeVersion (long version) 173 { 174 this.version = version; 175 } 176 177 public String getIconUrl () 178 { 179 return this.iconUrl; 180 } 181 182 public void setIconUrl (String url) 183 { 184 this.iconUrl = url; 185 } 186 187 189 191 193 195 } 196 | Popular Tags |