KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > tools > admin > DestinationTreeNode


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  * Initial developer(s): Alexander Fedorowicz
20  * Contributor(s):
21  */

22 package org.objectweb.joram.client.tools.admin;
23
24 import javax.swing.*;
25 import javax.swing.tree.*;
26
27 import org.objectweb.joram.client.jms.Destination;
28 import org.objectweb.joram.client.jms.Queue;
29 import org.objectweb.joram.client.jms.Topic;
30
31 class DestinationTreeNode extends DefaultMutableTreeNode
32     implements AdminTreeNode
33 {
34   protected AdminController c;
35   private Destination dest;
36   
37   public DestinationTreeNode(AdminController c, Destination dest)
38   {
39     super(dest);
40     this.c = c;
41     this.dest = dest;
42   }
43
44   public void refresh(DefaultTreeModel treeModel)
45   {
46   }
47
48   public String JavaDoc getDescription()
49   {
50     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
51     sb.append("<font face=Arial><b>");
52     sb.append(dest);
53     sb.append("</b><br><br>");
54
55     try {
56       Queue q = (Queue) dest;
57       sb.append("<b>Pending messages: </b>" + c.getPendingMessages(q) + "<br>");
58       sb.append("<b>Pending requests: </b>" + c.getPendingRequests(q) + "<br>");
59     }
60     catch (Exception JavaDoc exc) {System.err.println(exc);}
61
62     try {
63       Topic t = (Topic) dest;
64       sb.append("<b>Subscriptions: </b>" + c.getSubscriptions(t) + "<br>");
65     }
66     catch (Exception JavaDoc exc) {System.err.println(exc);}
67
68     sb.append("</font>");
69     return sb.toString();
70   }
71
72   public JPopupMenu getContextMenu()
73   {
74     JPopupMenu popup = new JPopupMenu("Destination");
75
76     return popup;
77   }
78
79   public ImageIcon getImageIcon()
80   {
81     return AdminToolConstants.queueIcon;
82   }
83
84   public Destination getDestination() { return dest; }
85
86   public ServerTreeNode getParentServerTreeNode() {
87     return (ServerTreeNode) getParent().getParent();
88   }
89   
90   public String JavaDoc toString() {
91     String JavaDoc name = c.findDestinationJndiName(dest);
92     if (name == null)
93         return dest.toString();
94     else
95         return name;
96   }
97
98   public boolean getAllowsChildren() {
99     return true;
100   }
101 }
102
Popular Tags