1 48 49 50 package org.exolab.jms.tools.admin; 51 52 import java.awt.Component ; 53 import java.awt.FlowLayout ; 54 55 import javax.swing.Box ; 56 import javax.swing.JPanel ; 57 import javax.swing.JTextField ; 58 import javax.swing.JTree ; 59 import javax.swing.UIManager ; 60 import javax.swing.tree.DefaultTreeCellRenderer ; 61 62 63 73 public class AdminInfo extends DefaultTreeCellRenderer { 74 75 protected JTextField field_ = new JTextField ("No Messages"); 77 78 private Component strut_ = Box.createHorizontalStrut(5); 81 82 private JPanel panel_ = new JPanel (); 84 85 90 public AdminInfo() { 91 panel_.setBackground(UIManager.getColor("Tree.textBackground")); 92 setOpaque(false); 93 field_.setOpaque(false); 94 panel_.setOpaque(false); 95 96 panel_.setLayout(new FlowLayout (FlowLayout.CENTER, 0, 0)); 97 panel_.add(this); 98 panel_.add(strut_); 99 panel_.add(field_); 100 } 101 102 103 120 public Component getTreeCellRendererComponent 121 (JTree tree, Object value, boolean selected, boolean expanded, 122 boolean leaf, int row, boolean hasFocus) { 123 super.getTreeCellRendererComponent(tree, value, selected, expanded, 124 leaf, row, hasFocus); 125 if (value instanceof OpenJMSNode) { 126 field_.setForeground(java.awt.Color.black); 127 if (value instanceof OpenJMSQueue) { 128 if (AbstractAdminConnection.instance() != null) { 129 OpenJMSQueue queue = (OpenJMSQueue) value; 130 131 int num = AbstractAdminConnection.instance().getQueueMessageCount( 132 queue.toString()); 133 String st = Integer.toString(num); 134 field_.setText(st); 135 field_.setVisible(true); 136 } 137 } else if (value instanceof OpenJMSTopic) { 138 field_.setVisible(false); 140 } else if (value instanceof OpenJMSUser) { 141 field_.setVisible(false); 143 } else if (value instanceof OpenJMSConsumer) { 144 if (AbstractAdminConnection.instance() != null) { 145 OpenJMSConsumer consumer = (OpenJMSConsumer) value; 146 OpenJMSTopic topic = (OpenJMSTopic) consumer.getParent(); 147 148 int num = AbstractAdminConnection.instance().getDurableConsumerMessageCount( 149 topic.toString(), consumer.toString()); 150 String st = Integer.toString(num); 151 152 if (AbstractAdminConnection.instance().isConnected( 153 consumer.toString())) { 154 field_.setForeground(java.awt.Color.red); 155 } 156 field_.setText(st); 157 field_.setVisible(true); 158 } 159 } 160 } else { 161 field_.setVisible(false); 162 } 163 164 return panel_; 165 } 166 167 } | Popular Tags |