1 4 package com.tc.admin.dso; 5 6 import com.tc.admin.ConnectionContext; 7 import com.tc.admin.common.XTreeNode; 8 9 import javax.swing.Icon ; 10 import javax.swing.SwingUtilities ; 11 12 public class MapEntryNode extends XTreeNode implements DSOObjectTreeNode { 13 protected ConnectionContext m_cc; 14 protected DSOMapEntryField m_field; 15 protected XTreeNode m_keyNode; 16 protected XTreeNode m_valueNode; 17 18 public MapEntryNode(ConnectionContext cc, DSOMapEntryField field) { 19 super(field); 20 21 m_cc = cc; 22 m_field = field; 23 24 initChildren(); 25 } 26 27 public DSOObject getDSOObject() { 28 return m_field; 29 } 30 31 protected void initChildren() { 32 RootsHelper helper = RootsHelper.getHelper(); 33 DSOObject key = m_field.getKey(); 34 DSOObject value = m_field.getValue(); 35 36 add(helper.createFieldNode(m_cc, key)); 37 38 XTreeNode valueNode; 39 if(value != null) { 40 valueNode = helper.createFieldNode(m_cc, value); 41 } else { 42 valueNode = new XTreeNode("value=null"); 43 } 44 add(valueNode); 45 46 if(key == null) { 47 SwingUtilities.invokeLater(new AncestorReaper()); 48 } 49 } 50 51 class AncestorReaper implements Runnable { 52 public void run() { 53 XTreeNode node = (XTreeNode)getParent(); 54 55 while(node != null) { 56 if(node instanceof FieldTreeNode) { 57 FieldTreeNode ftn = (FieldTreeNode)node; 58 59 if(ftn.getField().isValid()) { 60 ftn.refreshChildren(); 61 return; 62 } 63 } 64 else if(node instanceof RootTreeNode) { 65 ((RootTreeNode)node).refresh(); 66 return; 67 } 68 69 node = (XTreeNode)node.getParent(); 70 } 71 } 72 } 73 74 public Icon getIcon() { 75 return RootsHelper.getHelper().getFieldIcon(); 76 } 77 78 public void tearDown() { 79 super.tearDown(); 80 81 m_cc = null; 82 m_field = null; 83 m_keyNode = null; 84 m_valueNode = null; 85 } 86 } 87 88 89 | Popular Tags |