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