KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > event > WidgetEventMulticaster


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.woody.event;
17
18 import java.awt.AWTEventMulticaster JavaDoc;
19 import java.util.EventListener JavaDoc;
20
21 /**
22  * Convenience class to handle all widget event listeners. See
23  * <code>java.awt.AWTEventMulticaster</code> for more information on its use.
24  *
25  * @author <a HREF="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
26  * @version CVS $Id: WidgetEventMulticaster.java 30932 2004-07-29 17:35:38Z vgritsenko $
27  */

28 public class WidgetEventMulticaster extends AWTEventMulticaster JavaDoc implements
29     ActionListener, ValueChangedListener, ProcessingPhaseListener {
30
31     protected WidgetEventMulticaster(EventListener JavaDoc a, EventListener JavaDoc b) {
32         super(a, b);
33     }
34     
35     public static ActionListener add(ActionListener a, ActionListener b) {
36         return (ActionListener)addInternal(a, b);
37     }
38     
39     public static ActionListener remove(ActionListener l, ActionListener oldl) {
40         return (ActionListener)removeInternal(l, oldl);
41     }
42     
43     public void actionPerformed(ActionEvent e) {
44         ((ActionListener)a).actionPerformed(e);
45         ((ActionListener)b).actionPerformed(e);
46     }
47
48     public static ValueChangedListener add(ValueChangedListener a, ValueChangedListener b) {
49         return (ValueChangedListener)addInternal(a, b);
50     }
51     
52     public static ValueChangedListener remove(ValueChangedListener l, ValueChangedListener oldl) {
53         return (ValueChangedListener)removeInternal(l, oldl);
54     }
55     
56     public void phaseEnded(ProcessingPhaseEvent e) {
57         ((ProcessingPhaseListener)a).phaseEnded(e);
58         ((ProcessingPhaseListener)b).phaseEnded(e);
59     }
60     
61     public static ProcessingPhaseListener add(ProcessingPhaseListener a, ProcessingPhaseListener b) {
62         return (ProcessingPhaseListener)addInternal(a, b);
63     }
64     
65     public static ProcessingPhaseListener remove(ProcessingPhaseListener l, ProcessingPhaseListener oldl) {
66         return (ProcessingPhaseListener)removeInternal(l, oldl);
67     }
68     
69     public void valueChanged(ValueChangedEvent e) {
70         ((ValueChangedListener)a).valueChanged(e);
71         ((ValueChangedListener)b).valueChanged(e);
72     }
73     
74     /**
75      * Can't use the superclass method since it creates an AWTEventMulticaster
76      */

77     protected static EventListener JavaDoc addInternal(EventListener JavaDoc a, EventListener JavaDoc b) {
78         if (a == null) return b;
79         if (b == null) return a;
80         return new WidgetEventMulticaster(a, b);
81     }
82 }
83
Popular Tags