48b7597f1c09ac247b5d785799623ecdc9cb7824
[phpeclipse.git] /
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.internal.ui.preferences;
13
14 import org.eclipse.jface.preference.IPreferenceStore;
15 import org.eclipse.jface.util.IPropertyChangeListener;
16 // incastrix
17 //import org.eclipse.jface.util.ListenerList;
18 import org.eclipse.core.runtime.ListenerList;
19
20 import org.eclipse.jface.util.PropertyChangeEvent;
21
22 /**
23  * Mockup preference store, for registering listeners and firing events, without
24  * being an actual store.
25  * <p>
26  * All methods except firing, adding and removing listeners throw an
27  * {@link java.lang.UnsupportedOperationException}.
28  * </p>
29  * 
30  * @since 3.0
31  */
32 public class MockupPreferenceStore implements IPreferenceStore {
33
34         /** Listeners on this store */
35         private ListenerList fListeners = new ListenerList();
36
37         /**
38          * {@inheritDoc}
39          */
40         public void addPropertyChangeListener(IPropertyChangeListener listener) {
41                 fListeners.add(listener);
42         }
43
44         /**
45          * {@inheritDoc}
46          */
47         public void removePropertyChangeListener(IPropertyChangeListener listener) {
48                 fListeners.remove(listener);
49         }
50
51         /**
52          * {@inheritDoc}
53          */
54         public boolean contains(String name) {
55                 throw new UnsupportedOperationException();
56         }
57
58         /**
59          * {@inheritDoc}
60          */
61         public void firePropertyChangeEvent(String name, Object oldValue,
62                         Object newValue) {
63                 firePropertyChangeEvent(this, name, oldValue, newValue);
64         }
65
66         /**
67          * Fires a property change event with the given source, property name, old
68          * and new value. Used when the event source should be different from this
69          * mockup preference store.
70          * 
71          * @param source
72          *            The event source
73          * @param name
74          *            The property name
75          * @param oldValue
76          *            The property's old value
77          * @param newValue
78          *            The property's new value
79          */
80         public void firePropertyChangeEvent(Object source, String name,
81                         Object oldValue, Object newValue) {
82                 PropertyChangeEvent event = new PropertyChangeEvent(source, name,
83                                 oldValue, newValue);
84                 Object[] listeners = fListeners.getListeners();
85                 for (int i = 0; i < listeners.length; i++)
86                         ((IPropertyChangeListener) listeners[i]).propertyChange(event);
87         }
88
89         /**
90          * {@inheritDoc}
91          */
92         public boolean getBoolean(String name) {
93                 throw new UnsupportedOperationException();
94         }
95
96         /**
97          * {@inheritDoc}
98          */
99         public boolean getDefaultBoolean(String name) {
100                 throw new UnsupportedOperationException();
101         }
102
103         /**
104          * {@inheritDoc}
105          */
106         public double getDefaultDouble(String name) {
107                 throw new UnsupportedOperationException();
108         }
109
110         /**
111          * {@inheritDoc}
112          */
113         public float getDefaultFloat(String name) {
114                 throw new UnsupportedOperationException();
115         }
116
117         /**
118          * {@inheritDoc}
119          */
120         public int getDefaultInt(String name) {
121                 throw new UnsupportedOperationException();
122         }
123
124         /**
125          * {@inheritDoc}
126          */
127         public long getDefaultLong(String name) {
128                 throw new UnsupportedOperationException();
129         }
130
131         /**
132          * {@inheritDoc}
133          */
134         public String getDefaultString(String name) {
135                 throw new UnsupportedOperationException();
136         }
137
138         /**
139          * {@inheritDoc}
140          */
141         public double getDouble(String name) {
142                 throw new UnsupportedOperationException();
143         }
144
145         /**
146          * {@inheritDoc}
147          */
148         public float getFloat(String name) {
149                 throw new UnsupportedOperationException();
150         }
151
152         /**
153          * {@inheritDoc}
154          */
155         public int getInt(String name) {
156                 throw new UnsupportedOperationException();
157         }
158
159         /**
160          * {@inheritDoc}
161          */
162         public long getLong(String name) {
163                 throw new UnsupportedOperationException();
164         }
165
166         /**
167          * {@inheritDoc}
168          */
169         public String getString(String name) {
170                 throw new UnsupportedOperationException();
171         }
172
173         /**
174          * {@inheritDoc}
175          */
176         public boolean isDefault(String name) {
177                 throw new UnsupportedOperationException();
178         }
179
180         /**
181          * {@inheritDoc}
182          */
183         public boolean needsSaving() {
184                 throw new UnsupportedOperationException();
185         }
186
187         /**
188          * {@inheritDoc}
189          */
190         public void putValue(String name, String value) {
191                 throw new UnsupportedOperationException();
192         }
193
194         /**
195          * {@inheritDoc}
196          */
197         public void setDefault(String name, double value) {
198                 throw new UnsupportedOperationException();
199         }
200
201         /**
202          * {@inheritDoc}
203          */
204         public void setDefault(String name, float value) {
205                 throw new UnsupportedOperationException();
206         }
207
208         /**
209          * {@inheritDoc}
210          */
211         public void setDefault(String name, int value) {
212                 throw new UnsupportedOperationException();
213         }
214
215         /**
216          * {@inheritDoc}
217          */
218         public void setDefault(String name, long value) {
219                 throw new UnsupportedOperationException();
220         }
221
222         /**
223          * {@inheritDoc}
224          */
225         public void setDefault(String name, String defaultObject) {
226                 throw new UnsupportedOperationException();
227         }
228
229         /**
230          * {@inheritDoc}
231          */
232         public void setDefault(String name, boolean value) {
233                 throw new UnsupportedOperationException();
234         }
235
236         /**
237          * {@inheritDoc}
238          */
239         public void setToDefault(String name) {
240                 throw new UnsupportedOperationException();
241         }
242
243         /**
244          * {@inheritDoc}
245          */
246         public void setValue(String name, double value) {
247                 throw new UnsupportedOperationException();
248         }
249
250         /**
251          * {@inheritDoc}
252          */
253         public void setValue(String name, float value) {
254                 throw new UnsupportedOperationException();
255         }
256
257         /**
258          * {@inheritDoc}
259          */
260         public void setValue(String name, int value) {
261                 throw new UnsupportedOperationException();
262         }
263
264         /**
265          * {@inheritDoc}
266          */
267         public void setValue(String name, long value) {
268                 throw new UnsupportedOperationException();
269         }
270
271         /**
272          * {@inheritDoc}
273          */
274         public void setValue(String name, String value) {
275                 throw new UnsupportedOperationException();
276         }
277
278         /**
279          * {@inheritDoc}
280          */
281         public void setValue(String name, boolean value) {
282                 throw new UnsupportedOperationException();
283         }
284
285 }