/Users/lyon/j4p/src/j3d/viewer/TreeModelSupport.java
|
1 package j3d.viewer;
2
3
4 import javax.swing.event.TreeModelEvent;
5 import javax.swing.event.TreeModelListener;
6 import java.util.Enumeration;
7 import java.util.Vector;
8
9 public class TreeModelSupport {
10 private Vector vector = new Vector();
11
12 public void addTreeModelListener(TreeModelListener listener) {
13 if (listener != null && !vector.contains(listener)) {
14 vector.addElement(listener);
15 }
16 }
17
18 public void removeTreeModelListener(TreeModelListener listener) {
19 if (listener != null) {
20 vector.removeElement(listener);
21 }
22 }
23
24 public void fireTreeNodesChanged(TreeModelEvent e) {
25 Enumeration listeners = vector.elements();
26 while (listeners.hasMoreElements()) {
27 TreeModelListener listener = (TreeModelListener) listeners.nextElement();
28 listener.treeNodesChanged(e);
29 }
30 }
31
32 public void fireTreeNodesInserted(TreeModelEvent e) {
33 Enumeration listeners = vector.elements();
34 while (listeners.hasMoreElements()) {
35 TreeModelListener listener = (TreeModelListener) listeners.nextElement();
36 listener.treeNodesInserted(e);
37 }
38 }
39
40 public void fireTreeNodesRemoved(TreeModelEvent e) {
41 Enumeration listeners = vector.elements();
42 while (listeners.hasMoreElements()) {
43 TreeModelListener listener = (TreeModelListener) listeners.nextElement();
44 listener.treeNodesRemoved(e);
45 }
46 }
47
48 public void fireTreeStructureChanged(TreeModelEvent e) {
49 Enumeration listeners = vector.elements();
50 while (listeners.hasMoreElements()) {
51 TreeModelListener listener = (TreeModelListener) listeners.nextElement();
52 listener.treeStructureChanged(e);
53 }
54 }
55 }
56