allow listeners and notify them when classpath changes

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@606 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 60aaf6c986
commit bf41a3ccea
  1. 19
      jode/jode/swingui/PackagesTreeModel.java

@ -23,10 +23,12 @@ import jode.bytecode.ClassInfo;
///import javax.swing.tree.TreeModel; ///import javax.swing.tree.TreeModel;
///import javax.swing.tree.TreePath; ///import javax.swing.tree.TreePath;
///import javax.swing.event.TreeModelListener; ///import javax.swing.event.TreeModelListener;
///import javax.swing.event.TreeModelEvent;
///#else ///#else
import com.sun.java.swing.tree.TreeModel; import com.sun.java.swing.tree.TreeModel;
import com.sun.java.swing.tree.TreePath; import com.sun.java.swing.tree.TreePath;
import com.sun.java.swing.event.TreeModelListener; import com.sun.java.swing.event.TreeModelListener;
import com.sun.java.swing.event.TreeModelEvent;
///#endif ///#endif
import java.util.*; import java.util.*;
@ -79,6 +81,19 @@ public class PackagesTreeModel implements TreeModel {
} }
TreeElement root = new TreeElement("",""); TreeElement root = new TreeElement("","");
Vector listeners = new Vector();
public void rebuild() {
cachedChildrens.clear();
TreeModelListener[] ls;
synchronized (listeners) {
ls = new TreeModelListener[listeners.size()];
listeners.copyInto(ls);
}
TreeModelEvent ev = new TreeModelEvent(this, new Object[] { root });
for (int i=0; i< ls.length; i++)
ls[i].treeStructureChanged(ev);
}
public TreeElement[] getChildrens(TreeElement parent) { public TreeElement[] getChildrens(TreeElement parent) {
TreeElement[] result = TreeElement[] result =
@ -113,10 +128,10 @@ public class PackagesTreeModel implements TreeModel {
} }
public void addTreeModelListener(TreeModelListener l) { public void addTreeModelListener(TreeModelListener l) {
// we never change listeners.add(l);
} }
public void removeTreeModelListener(TreeModelListener l) { public void removeTreeModelListener(TreeModelListener l) {
// we never change listeners.remove(l);
} }
public void valueForPathChanged(TreePath path, Object newValue) { public void valueForPathChanged(TreePath path, Object newValue) {
// we don't allow values // we don't allow values

Loading…
Cancel
Save