1 7 package org.ejtools.jndi.browser.web.taglib; 8 9 import java.util.Hashtable ; 10 11 import org.ejtools.jndi.browser.model.JNDIEntry; 12 import org.ejtools.jndi.browser.model.JNDIEnvEntry; 13 import org.ejtools.jndi.browser.model.JNDILinkRef; 14 import org.ejtools.jndi.browser.model.Proxy; 15 import org.ejtools.servlet.http.jsp.tagext.tree.TreeRenderer; 16 17 25 public class TreeRendererImpl implements TreeRenderer 26 { 27 28 protected static Hashtable icons = new Hashtable (); 29 30 31 35 public String getDisplayName(Object o) 36 { 37 if (o != null) 38 { 39 StringBuffer buffer = new StringBuffer (); 40 41 if (o instanceof JNDILinkRef) 42 { 43 JNDILinkRef entry = (JNDILinkRef) o; 44 buffer.append(entry.getName()); 45 buffer.append(" => {"); 46 buffer.append(entry.getLinkName()); 47 buffer.append("}"); 48 49 return buffer.toString(); 50 } 51 if (o instanceof JNDIEnvEntry) 52 { 53 JNDIEnvEntry entry = (JNDIEnvEntry) o; 54 buffer.append(entry.getName()); 55 buffer.append(" ("); 56 buffer.append(entry.getClassName()); 57 buffer.append(") = "); 58 buffer.append(entry.getValue()); 59 60 return buffer.toString(); 61 } 62 if (o instanceof Proxy) 63 { 64 Proxy entry = (Proxy) o; 65 buffer.append(entry.getName()); 66 buffer.append(" ("); 67 for (int i = 0; i < entry.getInterfaces().length; i++) 68 { 69 if (i > 0) 70 { 71 buffer.append(","); 72 } 73 buffer.append(entry.getClassName()); 74 } 75 buffer.append(")"); 76 77 return buffer.toString(); 78 } 79 if (o instanceof JNDIEntry) 80 { 81 JNDIEntry entry = (JNDIEntry) o; 82 buffer.append(entry.getName()); 83 buffer.append(" ("); 84 buffer.append(entry.getClassName()); 85 buffer.append(")"); 86 87 return buffer.toString(); 88 } 89 90 return o.toString(); 91 } 92 return null; 93 } 94 95 96 102 public String getIcon(Object o) 103 { 104 String icon = (String ) icons.get(o.getClass()); 105 106 if (icon == null) 107 { 108 icon = "images/toolbarButtonGraphics/general/File16.gif"; 109 } 110 return icon; 111 } 112 113 114 static 115 { 116 icons.put(org.ejtools.jndi.browser.model.JNDIContext.class, "images/toolbarButtonGraphics/general/Folder16.gif"); 117 icons.put(org.ejtools.jndi.browser.model.JNDIEnvEntry.class, "images/toolbarButtonGraphics/general/File16.gif"); 118 icons.put(org.ejtools.jndi.browser.model.JNDILinkRef.class, "images/toolbarButtonGraphics/general/File16.gif"); 119 icons.put(org.ejtools.jndi.browser.model.ejb.EJBHomeProxy.class, "images/toolbarButtonGraphics/development/EJB16.gif"); 120 icons.put(org.ejtools.jndi.browser.model.ejb.EJBLocalHomeProxy.class, "images/toolbarButtonGraphics/development/EJB16.gif"); 121 icons.put(org.ejtools.jndi.browser.model.jms.QueueProxy.class, "images/toolbarButtonGraphics/development/JMSQueue16.gif"); 122 icons.put(org.ejtools.jndi.browser.model.jms.TopicProxy.class, "images/toolbarButtonGraphics/development/JMSTopic16.gif"); 123 icons.put(org.ejtools.jndi.browser.model.jms.ConnectionFactoryProxy.class, "images/toolbarButtonGraphics/development/Node16.gif"); 124 icons.put(org.ejtools.jndi.browser.model.mail.SessionProxy.class, "images/toolbarButtonGraphics/development/JavaMailResource16.gif"); 125 icons.put(org.ejtools.jndi.browser.model.sql.DataSourceProxy.class, "images/toolbarButtonGraphics/development/JDBCDataSource16.gif"); 126 } 127 } 128 | Popular Tags |