KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > tree > TreeModelChangeSupport


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.tree;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19 public class TreeModelChangeSupport {
20   TreeModel source;
21   ArrayList JavaDoc listeners = new ArrayList JavaDoc();
22
23   public TreeModelChangeSupport(TreeModel source) {
24     this.source = source;
25   }
26
27   public void fireModelChanged(boolean identityChanged, Object JavaDoc root) {
28     if (listeners.size() > 0) {
29       TreeModelChangeEvent event = new TreeModelChangeEvent(source, root, identityChanged);
30       List JavaDoc copy = (List JavaDoc) listeners.clone();
31       for (Iterator JavaDoc it = copy.iterator(); it.hasNext();)
32         ((TreeModelChangeListener) it.next()).treeModelChanged(event);
33     }
34   }
35
36   public void fireModelChanged(TreeModelChangeEvent event) {
37     fireModelChanged(event.isIdentityChanged(), event.getSubtree());
38   }
39
40   public void fireModelChanged(boolean identityChanged) {
41     fireModelChanged(identityChanged, null);
42   }
43
44   public void addTreeModelChangeListener(TreeModelChangeListener l) {
45     listeners.add(l);
46   }
47
48   public void removeTreeModelChangeListener(TreeModelChangeListener l) {
49     listeners.remove(l);
50   }
51
52 }
53
Popular Tags