1 package jde.debugger.gui;
3 import java.util.Enumeration;
4 import java.util.Vector;
5 import javax.swing.tree.DefaultTreeModel;
6 import javax.swing.tree.TreeNode;
8 import com.sun.jdi.PrimitiveType;
9 import com.sun.jdi.PrimitiveValue;
10 import com.sun.jdi.Value;
11 import jde.debugger.JDEException;
15 /** A TreeNode for primitive variables.
16 * @author <a href="mailto:udalrich@carolingia.org">Troy Daniels</a>
18 * @version $Revision: 1.2 $
20 class PrimitiveTreeNode extends LVTreeNode {
22 * @param name The name of the variable
23 * @param type The Type of the variable
24 * @param val The value of the variable.
25 * @param model The TreeModel.
27 protected PrimitiveTreeNode(String name,
30 DefaultTreeModel model) throws JDEException {
31 super(name, typeName, val, model);
32 if (!(m_type instanceof PrimitiveType))
33 throw new JDEException("PrimitiveTreeNode received non-primitive Type " + m_type.name());
34 if (!(val instanceof PrimitiveValue))
35 throw new JDEException("PrimitiveTreeNode received non-primitive value " + val.type().name());
40 /** Get the number of children.
41 * @return Zero, since primitives do not have children.
43 public int getChildCount() {
47 /** Returns if the node allows children
48 * @return false, since primitives do not have children. */
49 public boolean getAllowsChildren() {
53 /** Get the child at the given index.
54 * @throws IllegalArgumentException since primitives do not have children. */
55 public TreeNode getChildAt(int index) {
56 throw new IllegalArgumentException("Attempt to create a child of a Primitive");
59 /** Get the index of the tree node
60 * @return -1 since primitives do not have children */
61 public int getIndex(TreeNode node) { return -1; }
63 /** Get a string to represent the value of the variable */
65 return m_value.toString();
68 /** Asks if the node is a leaf node */
69 public boolean isLeaf() { return true; }
71 /** Returns an enumeration of the children */
72 public Enumeration children() {
73 return new Vector().elements();
76 /** Called when the value changes
77 * @param val The new value
79 void valueChanged(Value val) {
83 private Value m_value;