1 21 package org.jacorb.imr.util; 22 23 import javax.swing.tree.*; 24 import javax.swing.*; 25 import java.awt.Component ; 26 import org.jacorb.imr.*; 27 35 36 public class ImRTreeCellRenderer extends DefaultTreeCellRenderer { 37 private boolean m_use_html_labels = false; 38 39 public ImRTreeCellRenderer() { 40 super(); 41 } 42 43 46 public Component getTreeCellRendererComponent(JTree tree, Object value, 47 boolean sel, boolean expanded, 48 boolean leaf, int row, 49 boolean hasFocus) { 50 51 super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); 52 53 Object _node = ((DefaultMutableTreeNode) value).getUserObject(); 54 55 if (_node instanceof ImRInfo) { 56 setText("Repository"); 57 setToolTipText("Port: " + ((ImRInfo) _node).port + 58 ", Host: " + ((ImRInfo) _node).host); 59 } 60 else if (_node instanceof POAInfo){ 61 POAInfo _poa = (POAInfo) _node; 62 setToolTipText("POA is " 63 + ((_poa.active)? "active" : "inactive")); 64 65 if (m_use_html_labels){ 66 String _color = (_poa.active)? "green" : "red"; 67 setText("<html> <font color=" + _color + ">" + _poa.name + "</font></html>"); 68 } 69 else 70 setText(_poa.name); 71 } 72 else if (_node instanceof ServerInfo){ 73 ServerInfo _server = (ServerInfo) _node; 74 75 setToolTipText("Server is " 76 + ((_server.active)? "active" : "down") 77 + ((_server.holding)? "and holding" : "")); 78 79 if (m_use_html_labels){ 80 String _color = (_server.active)? "green" : "red"; 81 setText("<tml> <font color=" + _color + ">" + 82 ((_server.holding)? "<blink>" : "") + 83 _server.name + 84 ((_server.holding)? "</blink>" : "") + 85 "</font></html>"); 86 } 87 else 88 setText(_server.name); 89 } 90 return this; 91 } 92 } 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | Popular Tags |