01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.admin.dso;
05:
06: import com.tc.admin.ConnectionContext;
07: import com.tc.admin.common.XTreeNode;
08:
09: import javax.swing.Icon;
10: import javax.swing.SwingUtilities;
11:
12: public class MapEntryNode extends XTreeNode implements
13: DSOObjectTreeNode {
14: protected ConnectionContext m_cc;
15: protected DSOMapEntryField m_field;
16: protected XTreeNode m_keyNode;
17: protected XTreeNode m_valueNode;
18:
19: public MapEntryNode(ConnectionContext cc, DSOMapEntryField field) {
20: super (field);
21:
22: m_cc = cc;
23: m_field = field;
24:
25: initChildren();
26: }
27:
28: public DSOObject getDSOObject() {
29: return m_field;
30: }
31:
32: protected void initChildren() {
33: RootsHelper helper = RootsHelper.getHelper();
34: DSOObject key = m_field.getKey();
35: DSOObject value = m_field.getValue();
36:
37: add(helper.createFieldNode(m_cc, key));
38:
39: XTreeNode valueNode;
40: if (value != null) {
41: valueNode = helper.createFieldNode(m_cc, value);
42: } else {
43: valueNode = new XTreeNode("value=null");
44: }
45: add(valueNode);
46:
47: if (key == null) {
48: SwingUtilities.invokeLater(new AncestorReaper());
49: }
50: }
51:
52: class AncestorReaper implements Runnable {
53: public void run() {
54: XTreeNode node = (XTreeNode) getParent();
55:
56: while (node != null) {
57: if (node instanceof FieldTreeNode) {
58: FieldTreeNode ftn = (FieldTreeNode) node;
59:
60: if (ftn.getField().isValid()) {
61: ftn.refreshChildren();
62: return;
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: }
|