KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > selection > SelectionChangeSupport


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.selection;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19 import com.tonbeller.wcf.controller.RequestContext;
20
21 public class SelectionChangeSupport {
22
23   ArrayList JavaDoc listeners = new ArrayList JavaDoc();
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 JavaDoc copy = (List JavaDoc) listeners.clone();
34       for (Iterator JavaDoc 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