KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jndi > browser > web > taglib > TreeRendererImpl


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.jndi.browser.web.taglib;
8
9 import java.util.Hashtable JavaDoc;
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 /**
18  * Description of the Class
19  *
20  * @author letiemble
21  * @created 25 avril 2002
22  * @version $Revision: 1.2 $
23  * @todo Javadoc to complete
24  */

25 public class TreeRendererImpl implements TreeRenderer
26 {
27    /** Description of the Field */
28    protected static Hashtable JavaDoc icons = new Hashtable JavaDoc();
29
30
31    /**
32     * @param o Description of the Parameter
33     * @return The displayName value
34     */

35    public String JavaDoc getDisplayName(Object JavaDoc o)
36    {
37       if (o != null)
38       {
39          StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
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    /**
97     * Gets the icon attribute of the TreeRendererImpl object
98     *
99     * @param o Description of the Parameter
100     * @return The icon value
101     */

102    public String JavaDoc getIcon(Object JavaDoc o)
103    {
104       String JavaDoc icon = (String JavaDoc) icons.get(o.getClass());
105
106       if (icon == null)
107       {
108          icon = "images/toolbarButtonGraphics/general/File16.gif";
109       }
110       return icon;
111    }
112
113    /** Map of the class/icons */
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