1 13 package com.tonbeller.wcf.selection; 14 15 import java.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 19 import com.tonbeller.wcf.controller.RequestContext; 20 21 public class SelectionChangeSupport { 22 23 ArrayList listeners = new ArrayList (); 24 SelectionModel source; 25 26 public SelectionChangeSupport(SelectionModel source) { 27 this.source = source; 28 } 29 30 public void fireSelectionChanged(RequestContext context) { 31 if (listeners.size() > 0) { 32 SelectionChangeEvent event = new SelectionChangeEvent(context, source); 33 List copy = (List ) listeners.clone(); 34 for (Iterator it = copy.iterator(); it.hasNext();) 35 ((SelectionChangeListener) it.next()).selectionChanged(event); 36 } 37 } 38 39 public void addSelectionListener(SelectionChangeListener l) { 40 listeners.add(l); 41 } 42 43 public void removeSelectionListener(SelectionChangeListener l) { 44 listeners.remove(l); 45 } 46 47 } 48 | Popular Tags |