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