1 13 package com.tonbeller.wcf.catedit; 14 15 import java.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 19 20 25 public class CategoryModelSupport implements CategoryModel { 26 27 List categories = new ArrayList (); 28 ArrayList listeners = new ArrayList (); 29 30 34 public List getCategories() { 35 return categories; 36 } 37 38 42 public void setCategories(List 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 copy = (List ) listeners.clone(); 58 for (Iterator it = copy.iterator(); it.hasNext();) 59 ((CategoryModelChangeListener) it.next()).categoryModelChanged(event); 60 } 61 } 62 63 } 64 | Popular Tags |