KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > forms > 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.forms.event;
17
18 import java.awt.AWTEventMulticaster JavaDoc;
19 import java.util.EventListener JavaDoc;
20
21 import org.apache.cocoon.forms.formmodel.tree.TreeSelectionEvent;
22 import org.apache.cocoon.forms.formmodel.tree.TreeSelectionListener;
23
24 /**
25  * Convenience class to handle all widget event listeners. See
26  * <code>java.awt.AWTEventMulticaster</code> for more information on its use.
27  *
28  * @author <a HREF="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
29  * @version $Id: WidgetEventMulticaster.java 190962 2005-06-16 17:17:00Z sylvain $
30  */

31 public class WidgetEventMulticaster extends AWTEventMulticaster JavaDoc implements
32     ActionListener, ValueChangedListener, ProcessingPhaseListener {
33
34     protected WidgetEventMulticaster(EventListener JavaDoc a, EventListener JavaDoc b) {
35         super(a, b);
36     }
37     
38     //-- Create ---------------------------------------------------------------
39

40     public static CreateListener add(CreateListener a, CreateListener b) {
41         return (CreateListener)addInternal(a, b);
42     }
43     
44     public static CreateListener remove(CreateListener l, CreateListener oldl) {
45         return (CreateListener)removeInternal(l, oldl);
46     }
47     
48     public void widgetCreated(CreateEvent e) {
49         ((CreateListener)a).widgetCreated(e);
50         ((CreateListener)b).widgetCreated(e);
51     }
52
53     //-- Action ---------------------------------------------------------------
54

55     public static ActionListener add(ActionListener a, ActionListener b) {
56         return (ActionListener)addInternal(a, b);
57     }
58     
59     public static ActionListener remove(ActionListener l, ActionListener oldl) {
60         return (ActionListener)removeInternal(l, oldl);
61     }
62     
63     public void actionPerformed(ActionEvent e) {
64         ((ActionListener)a).actionPerformed(e);
65         ((ActionListener)b).actionPerformed(e);
66     }
67
68     //-- ValueChanged ---------------------------------------------------------
69

70     public static ValueChangedListener add(ValueChangedListener a, ValueChangedListener b) {
71         return (ValueChangedListener)addInternal(a, b);
72     }
73     
74     public static ValueChangedListener remove(ValueChangedListener l, ValueChangedListener oldl) {
75         return (ValueChangedListener)removeInternal(l, oldl);
76     }
77     
78     public void valueChanged(ValueChangedEvent e) {
79         ((ValueChangedListener)a).valueChanged(e);
80         ((ValueChangedListener)b).valueChanged(e);
81     }
82     
83     //-- ProcessingPhase ------------------------------------------------------
84

85     public void phaseEnded(ProcessingPhaseEvent e) {
86         ((ProcessingPhaseListener)a).phaseEnded(e);
87         ((ProcessingPhaseListener)b).phaseEnded(e);
88     }
89     
90     public static ProcessingPhaseListener add(ProcessingPhaseListener a, ProcessingPhaseListener b) {
91         return (ProcessingPhaseListener)addInternal(a, b);
92     }
93     
94     public static ProcessingPhaseListener remove(ProcessingPhaseListener l, ProcessingPhaseListener oldl) {
95         return (ProcessingPhaseListener)removeInternal(l, oldl);
96     }
97     
98     //-- TreeSelectionChanged ---------------------------------------------------------
99

100     public static TreeSelectionListener add(TreeSelectionListener a, TreeSelectionListener b) {
101         return (TreeSelectionListener)addInternal(a, b);
102     }
103     
104     public static TreeSelectionListener remove(TreeSelectionListener l, TreeSelectionListener oldl) {
105         return (TreeSelectionListener)removeInternal(l, oldl);
106     }
107     
108     public void selectionChanged(TreeSelectionEvent e) {
109         ((TreeSelectionListener)a).selectionChanged(e);
110         ((TreeSelectionListener)b).selectionChanged(e);
111     }
112
113     /**
114      * Can't use the superclass method since it creates an AWTEventMulticaster
115      */

116     protected static EventListener JavaDoc addInternal(EventListener JavaDoc a, EventListener JavaDoc b) {
117         if (a == null) return b;
118         if (b == null) return a;
119         return new WidgetEventMulticaster(a, b);
120     }
121 }
122
Popular Tags