Methods Summary |
---|
public void | addTreeModelListener(javax.swing.event.TreeModelListener tml)
if (listeners == null) { listeners = new Vector(); }
listeners.addElement(tml);
|
protected void | fireTreeNodesChanged(java.lang.Object source, java.lang.Object[] path, int[] ci, java.lang.Object[] cc) // Short, but not very thread safe!!
if (listeners != null) {
TreeModelEvent tme = new TreeModelEvent(source, path, ci, cc);
for (int i = 0; i < listeners.size(); i++) {
((TreeModelListener)listeners.elementAt(i)).treeNodesChanged(tme);
}
}
|
public java.lang.Object | getChild(java.lang.Object node, int index)
if (node instanceof OpNode) { return ((OpNode)node).getChild(index); }
return null;
|
public int | getChildCount(java.lang.Object parent)
if (parent instanceof OpNode) { return ((OpNode)parent).getChildCount(); }
else { return 0; }
|
public int | getIndexOfChild(java.lang.Object parent, java.lang.Object child)
if (parent instanceof OpNode) {
return ((OpNode)parent).getIndexOfChild(child);
}
else { return -1; }
|
public java.lang.Object | getRoot() return root;
|
public void | insertNode(OpNode parent, java.lang.Object node, int index)
parent.setChild(index, node);
|
public boolean | isLeaf(java.lang.Object node) return (!(node instanceof OpNode));
|
public void | refresh(javax.swing.event.TreeExpansionEvent tee)
int[] ci = new int[] { -1 };
fireTreeNodesChanged(tee.getSource(), tee.getPath().getPath(), ci, null);
|
public void | removeTreeModelListener(javax.swing.event.TreeModelListener tml)
if (listeners != null) { listeners.removeElement(tml); }
|
public void | valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
Object[] p = path.getPath();
Object[] pp = p;
Object node;
int index;
if (p.length == 1) { //editing root . . .
root.setOperator(newValue);
node = root;
index = -1;
}
else {
node = p[p.length - 1];
OpNode parent = (OpNode)p[p.length - 2];
index = parent.getIndexOfChild(node);
if (node instanceof OpNode) {((OpNode)node).setOperator(newValue);}
else {
// Play a few path games since Integer is a noneditable object. We'll say
// that the changed node is our parent, not us.
parent.setChild(index, newValue);
node = parent.getChild(index);
// Create a new path down to our parent, but don't include us
pp = new Object[p.length - 1];
for (int i = 0; i < pp.length; i++) {pp[i]=p[i];}
}
}
int[] ci = new int[] { index }; // child indices in parent
Object [] cc = new Object[] { node }; // child objects in parent
fireTreeNodesChanged(this, pp, ci, cc);
|