KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > model > ConfigurationNotifier


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui.model;
25
26 import org.objectweb.fractal.api.control.BindingController;
27
28 import java.util.Map JavaDoc;
29 import java.util.HashMap JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 /**
33  * A {@link ConfigurationListener} that notifies other {@link
34  * ConfigurationListener}s.
35  */

36
37 public class ConfigurationNotifier implements
38   ConfigurationListener,
39   BindingController
40 {
41
42   /**
43    * A collection client interface bound to the {@link ConfigurationListener
44    * listeners} of this component.
45    */

46
47   public final static String JavaDoc CONFIGURATION_LISTENERS_BINDING =
48     "configuration-listeners";
49
50   /**
51    * The listeners client interface.
52    */

53
54   private Map JavaDoc listeners;
55
56   /**
57    * Constructs a new configuration notifier component.
58    */

59
60   public ConfigurationNotifier () {
61     listeners = new HashMap JavaDoc();
62   }
63
64   // -------------------------------------------------------------------------
65
// Implementation of the BindingController interface
66
// -------------------------------------------------------------------------
67

68   public String JavaDoc[] listFc () {
69     return (String JavaDoc[])listeners.keySet().toArray(new String JavaDoc[listeners.size()]);
70   }
71
72   public Object JavaDoc lookupFc (final String JavaDoc clientItfName) {
73     if (clientItfName.startsWith(CONFIGURATION_LISTENERS_BINDING)) {
74       return listeners.get(clientItfName);
75     }
76     return null;
77   }
78
79   public void bindFc (
80     final String JavaDoc clientItfName,
81     final Object JavaDoc serverItf)
82   {
83     if (clientItfName.startsWith(CONFIGURATION_LISTENERS_BINDING)) {
84       listeners.put(clientItfName, serverItf);
85     }
86   }
87
88   public void unbindFc (final String JavaDoc clientItfName) {
89     if (clientItfName.startsWith(CONFIGURATION_LISTENERS_BINDING)) {
90       listeners.remove(clientItfName);
91     }
92   }
93
94   // -------------------------------------------------------------------------
95
// Implementation of the ConfigurationListener interface
96
// -------------------------------------------------------------------------
97

98   public void changeCountChanged (Component component, long changeCount) {
99     Iterator JavaDoc i = listeners.values().iterator();
100     while (i.hasNext()) {
101       ConfigurationListener l = (ConfigurationListener)i.next();
102       l.changeCountChanged(component, changeCount);
103     }
104   }
105
106   public void rootComponentChanged (final Component oldValue) {
107     Iterator JavaDoc i = listeners.values().iterator();
108     while (i.hasNext()) {
109       ConfigurationListener l = (ConfigurationListener)i.next();
110       l.rootComponentChanged(oldValue);
111     }
112   }
113
114   public void nameChanged (final Component component, final String JavaDoc oldValue) {
115     Iterator JavaDoc i = listeners.values().iterator();
116     while (i.hasNext()) {
117       ConfigurationListener l = (ConfigurationListener)i.next();
118       l.nameChanged(component, oldValue);
119     }
120   }
121
122   public void typeChanged (final Component component, final String JavaDoc oldValue) {
123     Iterator JavaDoc i = listeners.values().iterator();
124     while (i.hasNext()) {
125       ConfigurationListener l = (ConfigurationListener)i.next();
126       l.typeChanged(component, oldValue);
127     }
128   }
129
130   public void implementationChanged (
131     final Component component,
132     final String JavaDoc oldValue)
133   {
134     Iterator JavaDoc i = listeners.values().iterator();
135     while (i.hasNext()) {
136       ConfigurationListener l = (ConfigurationListener)i.next();
137       l.implementationChanged(component, oldValue);
138     }
139   }
140
141   public void interfaceNameChanged (final Interface i, final String JavaDoc oldValue) {
142     Iterator JavaDoc j = listeners.values().iterator();
143     while (j.hasNext()) {
144       ConfigurationListener l = (ConfigurationListener)j.next();
145       l.interfaceNameChanged(i, oldValue);
146     }
147   }
148
149   public void interfaceSignatureChanged (
150     final Interface i,
151     final String JavaDoc oldValue)
152   {
153     Iterator JavaDoc j = listeners.values().iterator();
154     while (j.hasNext()) {
155       ConfigurationListener l = (ConfigurationListener)j.next();
156       l.interfaceSignatureChanged(i, oldValue);
157     }
158   }
159
160   public void interfaceContingencyChanged (
161     final Interface i,
162     final boolean oldValue)
163   {
164     Iterator JavaDoc j = listeners.values().iterator();
165     while (j.hasNext()) {
166       ConfigurationListener l = (ConfigurationListener)j.next();
167       l.interfaceContingencyChanged(i, oldValue);
168     }
169   }
170
171   public void interfaceCardinalityChanged (
172     final Interface i,
173     final boolean oldValue)
174   {
175     Iterator JavaDoc j = listeners.values().iterator();
176     while (j.hasNext()) {
177       ConfigurationListener l = (ConfigurationListener)j.next();
178       l.interfaceCardinalityChanged(i, oldValue);
179     }
180   }
181
182   public void clientInterfaceAdded (
183     final Component component,
184     final ClientInterface i,
185     final int index)
186   {
187     Iterator JavaDoc j = listeners.values().iterator();
188     while (j.hasNext()) {
189       ConfigurationListener l = (ConfigurationListener)j.next();
190       l.clientInterfaceAdded(component, i, index);
191     }
192   }
193
194   public void clientInterfaceRemoved (
195     final Component component,
196     final ClientInterface i,
197     final int index)
198   {
199     Iterator JavaDoc j = listeners.values().iterator();
200     while (j.hasNext()) {
201       ConfigurationListener l = (ConfigurationListener)j.next();
202       l.clientInterfaceRemoved(component, i, index);
203     }
204   }
205
206   public void serverInterfaceAdded (
207     final Component component,
208     final ServerInterface i,
209     final int index)
210   {
211     Iterator JavaDoc j = listeners.values().iterator();
212     while (j.hasNext()) {
213       ConfigurationListener l = (ConfigurationListener)j.next();
214       l.serverInterfaceAdded(component, i, index);
215     }
216   }
217
218   public void serverInterfaceRemoved (
219     final Component component,
220     final ServerInterface i,
221     final int index)
222   {
223     Iterator JavaDoc j = listeners.values().iterator();
224     while (j.hasNext()) {
225       ConfigurationListener l = (ConfigurationListener)j.next();
226       l.serverInterfaceRemoved(component, i, index);
227     }
228   }
229
230   public void interfaceBound (
231     final ClientInterface citf, final ServerInterface sitf)
232   {
233     Iterator JavaDoc i = listeners.values().iterator();
234     while (i.hasNext()) {
235       ConfigurationListener l = (ConfigurationListener)i.next();
236       l.interfaceBound(citf, sitf);
237     }
238   }
239
240   public void interfaceRebound (
241     final ClientInterface citf,
242     final ServerInterface oldSitf)
243   {
244     Iterator JavaDoc i = listeners.values().iterator();
245     while (i.hasNext()) {
246       ConfigurationListener l = (ConfigurationListener)i.next();
247       l.interfaceRebound(citf, oldSitf);
248     }
249   }
250
251   public void interfaceUnbound (
252     final ClientInterface citf,
253     final ServerInterface sitf)
254   {
255     Iterator JavaDoc i = listeners.values().iterator();
256     while (i.hasNext()) {
257       ConfigurationListener l = (ConfigurationListener)i.next();
258       l.interfaceUnbound(citf, sitf);
259     }
260   }
261
262   public void attributeControllerChanged (
263     final Component component,
264     final String JavaDoc oldValue)
265   {
266     Iterator JavaDoc i = listeners.values().iterator();
267     while (i.hasNext()) {
268       ConfigurationListener l = (ConfigurationListener)i.next();
269       l.attributeControllerChanged(component, oldValue);
270     }
271   }
272
273   public void attributeChanged (
274     final Component component,
275     final String JavaDoc attributeName,
276     final String JavaDoc oldValue)
277   {
278     Iterator JavaDoc i = listeners.values().iterator();
279     while (i.hasNext()) {
280       ConfigurationListener l = (ConfigurationListener)i.next();
281       l.attributeChanged(component, attributeName, oldValue);
282     }
283   }
284
285   public void templateControllerDescriptorChanged (
286     final Component component,
287     final String JavaDoc oldValue)
288   {
289     Iterator JavaDoc i = listeners.values().iterator();
290     while (i.hasNext()) {
291       ConfigurationListener l = (ConfigurationListener)i.next();
292       l.templateControllerDescriptorChanged(component, oldValue);
293     }
294   }
295
296   public void componentControllerDescriptorChanged (
297     final Component component,
298     final String JavaDoc oldValue)
299   {
300     Iterator JavaDoc i = listeners.values().iterator();
301     while (i.hasNext()) {
302       ConfigurationListener l = (ConfigurationListener)i.next();
303       l.componentControllerDescriptorChanged(component, oldValue);
304     }
305   }
306
307   public void subComponentAdded (
308     final Component parent,
309     final Component child,
310     final int index)
311   {
312     Iterator JavaDoc i = listeners.values().iterator();
313     while (i.hasNext()) {
314       ConfigurationListener l = (ConfigurationListener)i.next();
315       l.subComponentAdded(parent, child, index);
316     }
317   }
318
319   public void subComponentRemoved (
320     final Component parent,
321     final Component child,
322     final int index)
323   {
324     Iterator JavaDoc i = listeners.values().iterator();
325     while (i.hasNext()) {
326       ConfigurationListener l = (ConfigurationListener)i.next();
327       l.subComponentRemoved(parent, child, index);
328     }
329   }
330 }
331
Popular Tags