refactory: added UI removed from core plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / 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, without
21  * being an actual store.
22  * <p>
23  * All methods except firing, adding and removing listeners throw an
24  * {@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,
59                         Object newValue) {
60                 firePropertyChangeEvent(this, name, oldValue, newValue);
61         }
62
63         /**
64          * Fires a property change event with the given source, property name, old
65          * and new value. Used when the event source should be different from this
66          * mockup preference store.
67          * 
68          * @param source
69          *            The event source
70          * @param name
71          *            The property name
72          * @param oldValue
73          *            The property's old value
74          * @param newValue
75          *            The property's new value
76          */
77         public void firePropertyChangeEvent(Object source, String name,
78                         Object oldValue, Object newValue) {
79                 PropertyChangeEvent event = new PropertyChangeEvent(source, name,
80                                 oldValue, newValue);
81                 Object[] listeners = fListeners.getListeners();
82                 for (int i = 0; i < listeners.length; i++)
83                         ((IPropertyChangeListener) listeners[i]).propertyChange(event);
84         }
85
86         /**
87          * {@inheritDoc}
88          */
89         public boolean getBoolean(String name) {
90                 throw new UnsupportedOperationException();
91         }
92
93         /**
94          * {@inheritDoc}
95          */
96         public boolean getDefaultBoolean(String name) {
97                 throw new UnsupportedOperationException();
98         }
99
100         /**
101          * {@inheritDoc}
102          */
103         public double getDefaultDouble(String name) {
104                 throw new UnsupportedOperationException();
105         }
106
107         /**
108          * {@inheritDoc}
109          */
110         public float getDefaultFloat(String name) {
111                 throw new UnsupportedOperationException();
112         }
113
114         /**
115          * {@inheritDoc}
116          */
117         public int getDefaultInt(String name) {
118                 throw new UnsupportedOperationException();
119         }
120
121         /**
122          * {@inheritDoc}
123          */
124         public long getDefaultLong(String name) {
125                 throw new UnsupportedOperationException();
126         }
127
128         /**
129          * {@inheritDoc}
130          */
131         public String getDefaultString(String name) {
132                 throw new UnsupportedOperationException();
133         }
134
135         /**
136          * {@inheritDoc}
137          */
138         public double getDouble(String name) {
139                 throw new UnsupportedOperationException();
140         }
141
142         /**
143          * {@inheritDoc}
144          */
145         public float getFloat(String name) {
146                 throw new UnsupportedOperationException();
147         }
148
149         /**
150          * {@inheritDoc}
151          */
152         public int getInt(String name) {
153                 throw new UnsupportedOperationException();
154         }
155
156         /**
157          * {@inheritDoc}
158          */
159         public long getLong(String name) {
160                 throw new UnsupportedOperationException();
161         }
162
163         /**
164          * {@inheritDoc}
165          */
166         public String getString(String name) {
167                 throw new UnsupportedOperationException();
168         }
169
170         /**
171          * {@inheritDoc}
172          */
173         public boolean isDefault(String name) {
174                 throw new UnsupportedOperationException();
175         }
176
177         /**
178          * {@inheritDoc}
179          */
180         public boolean needsSaving() {
181                 throw new UnsupportedOperationException();
182         }
183
184         /**
185          * {@inheritDoc}
186          */
187         public void putValue(String name, String value) {
188                 throw new UnsupportedOperationException();
189         }
190
191         /**
192          * {@inheritDoc}
193          */
194         public void setDefault(String name, double value) {
195                 throw new UnsupportedOperationException();
196         }
197
198         /**
199          * {@inheritDoc}
200          */
201         public void setDefault(String name, float value) {
202                 throw new UnsupportedOperationException();
203         }
204
205         /**
206          * {@inheritDoc}
207          */
208         public void setDefault(String name, int value) {
209                 throw new UnsupportedOperationException();
210         }
211
212         /**
213          * {@inheritDoc}
214          */
215         public void setDefault(String name, long value) {
216                 throw new UnsupportedOperationException();
217         }
218
219         /**
220          * {@inheritDoc}
221          */
222         public void setDefault(String name, String defaultObject) {
223                 throw new UnsupportedOperationException();
224         }
225
226         /**
227          * {@inheritDoc}
228          */
229         public void setDefault(String name, boolean value) {
230                 throw new UnsupportedOperationException();
231         }
232
233         /**
234          * {@inheritDoc}
235          */
236         public void setToDefault(String name) {
237                 throw new UnsupportedOperationException();
238         }
239
240         /**
241          * {@inheritDoc}
242          */
243         public void setValue(String name, double value) {
244                 throw new UnsupportedOperationException();
245         }
246
247         /**
248          * {@inheritDoc}
249          */
250         public void setValue(String name, float value) {
251                 throw new UnsupportedOperationException();
252         }
253
254         /**
255          * {@inheritDoc}
256          */
257         public void setValue(String name, int value) {
258                 throw new UnsupportedOperationException();
259         }
260
261         /**
262          * {@inheritDoc}
263          */
264         public void setValue(String name, long value) {
265                 throw new UnsupportedOperationException();
266         }
267
268         /**
269          * {@inheritDoc}
270          */
271         public void setValue(String name, String value) {
272                 throw new UnsupportedOperationException();
273         }
274
275         /**
276          * {@inheritDoc}
277          */
278         public void setValue(String name, boolean value) {
279                 throw new UnsupportedOperationException();
280         }
281
282 }