01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.woody.event;
18:
19: import java.awt.AWTEventMulticaster;
20: import java.util.EventListener;
21:
22: /**
23: * Convenience class to handle all widget event listeners. See
24: * <code>java.awt.AWTEventMulticaster</code> for more information on its use.
25: *
26: * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
27: * @version CVS $Id: WidgetEventMulticaster.java 433543 2006-08-22 06:22:54Z crossley $
28: */
29: public class WidgetEventMulticaster extends AWTEventMulticaster
30: implements ActionListener, ValueChangedListener,
31: ProcessingPhaseListener {
32:
33: protected WidgetEventMulticaster(EventListener a, EventListener b) {
34: super (a, b);
35: }
36:
37: public static ActionListener add(ActionListener a, ActionListener b) {
38: return (ActionListener) addInternal(a, b);
39: }
40:
41: public static ActionListener remove(ActionListener l,
42: ActionListener oldl) {
43: return (ActionListener) removeInternal(l, oldl);
44: }
45:
46: public void actionPerformed(ActionEvent e) {
47: ((ActionListener) a).actionPerformed(e);
48: ((ActionListener) b).actionPerformed(e);
49: }
50:
51: public static ValueChangedListener add(ValueChangedListener a,
52: ValueChangedListener b) {
53: return (ValueChangedListener) addInternal(a, b);
54: }
55:
56: public static ValueChangedListener remove(ValueChangedListener l,
57: ValueChangedListener oldl) {
58: return (ValueChangedListener) removeInternal(l, oldl);
59: }
60:
61: public void phaseEnded(ProcessingPhaseEvent e) {
62: ((ProcessingPhaseListener) a).phaseEnded(e);
63: ((ProcessingPhaseListener) b).phaseEnded(e);
64: }
65:
66: public static ProcessingPhaseListener add(
67: ProcessingPhaseListener a, ProcessingPhaseListener b) {
68: return (ProcessingPhaseListener) addInternal(a, b);
69: }
70:
71: public static ProcessingPhaseListener remove(
72: ProcessingPhaseListener l, ProcessingPhaseListener oldl) {
73: return (ProcessingPhaseListener) removeInternal(l, oldl);
74: }
75:
76: public void valueChanged(ValueChangedEvent e) {
77: ((ValueChangedListener) a).valueChanged(e);
78: ((ValueChangedListener) b).valueChanged(e);
79: }
80:
81: /**
82: * Can't use the superclass method since it creates an AWTEventMulticaster
83: */
84: protected static EventListener addInternal(EventListener a,
85: EventListener b) {
86: if (a == null)
87: return b;
88: if (b == null)
89: return a;
90: return new WidgetEventMulticaster(a, b);
91: }
92: }
|