KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > catedit > CategoryModelSupport


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.catedit;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19
20 /**
21  * Created on 09.12.2002
22  *
23  * @author av
24  */

25 public class CategoryModelSupport implements CategoryModel {
26
27   List JavaDoc categories = new ArrayList JavaDoc();
28   ArrayList JavaDoc listeners = new ArrayList JavaDoc();
29
30   /**
31    * Returns the categories.
32    * @return List
33    */

34   public List JavaDoc getCategories() {
35     return categories;
36   }
37
38   /**
39    * Sets the categories.
40    * @param categories The categories to set
41    */

42   public void setCategories(List JavaDoc categories) {
43     this.categories = categories;
44   }
45
46   public void addCategoryModelChangeListener(CategoryModelChangeListener l) {
47     listeners.add(l);
48   }
49
50   public void removeCategoryModelChangeListener(CategoryModelChangeListener l) {
51     listeners.remove(l);
52   }
53
54   public void fireModelChanged() {
55     if (listeners.size() > 0) {
56       CategoryModelChangeEvent event = new CategoryModelChangeEvent(this);
57       List JavaDoc copy = (List JavaDoc) listeners.clone();
58       for (Iterator JavaDoc it = copy.iterator(); it.hasNext();)
59          ((CategoryModelChangeListener) it.next()).categoryModelChanged(event);
60     }
61   }
62
63 }
64
Popular Tags