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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package org.eclipse.jdt.internal.ui.preferences;
14 import org.eclipse.core.runtime.ListenerList;
16 import org.eclipse.jface.preference.IPreferenceStore;
17 import org.eclipse.jface.util.IPropertyChangeListener;
18 import org.eclipse.jface.util.PropertyChangeEvent;
21 * Mockup preference store, for registering listeners and firing events,
22 * without being an actual store.
24 * All methods except firing, adding and removing listeners throw
25 * an {@link java.lang.UnsupportedOperationException}.
30 public class MockupPreferenceStore implements IPreferenceStore {
32 /** Listeners on this store */
33 private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
38 public void addPropertyChangeListener(IPropertyChangeListener listener) {
39 fListeners.add(listener);
45 public void removePropertyChangeListener(IPropertyChangeListener listener) {
46 fListeners.remove(listener);
52 public boolean contains(String name) {
53 throw new UnsupportedOperationException();
59 public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
60 firePropertyChangeEvent(this, name, oldValue, newValue);
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
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);
81 public boolean getBoolean(String name) {
82 throw new UnsupportedOperationException();
88 public boolean getDefaultBoolean(String name) {
89 throw new UnsupportedOperationException();
95 public double getDefaultDouble(String name) {
96 throw new UnsupportedOperationException();
102 public float getDefaultFloat(String name) {
103 throw new UnsupportedOperationException();
109 public int getDefaultInt(String name) {
110 throw new UnsupportedOperationException();
116 public long getDefaultLong(String name) {
117 throw new UnsupportedOperationException();
123 public String getDefaultString(String name) {
124 throw new UnsupportedOperationException();
130 public double getDouble(String name) {
131 throw new UnsupportedOperationException();
137 public float getFloat(String name) {
138 throw new UnsupportedOperationException();
144 public int getInt(String name) {
145 throw new UnsupportedOperationException();
151 public long getLong(String name) {
152 throw new UnsupportedOperationException();
158 public String getString(String name) {
159 throw new UnsupportedOperationException();
165 public boolean isDefault(String name) {
166 throw new UnsupportedOperationException();
172 public boolean needsSaving() {
173 throw new UnsupportedOperationException();
179 public void putValue(String name, String value) {
180 throw new UnsupportedOperationException();
186 public void setDefault(String name, double value) {
187 throw new UnsupportedOperationException();
193 public void setDefault(String name, float value) {
194 throw new UnsupportedOperationException();
200 public void setDefault(String name, int value) {
201 throw new UnsupportedOperationException();
207 public void setDefault(String name, long value) {
208 throw new UnsupportedOperationException();
214 public void setDefault(String name, String defaultObject) {
215 throw new UnsupportedOperationException();
221 public void setDefault(String name, boolean value) {
222 throw new UnsupportedOperationException();
228 public void setToDefault(String name) {
229 throw new UnsupportedOperationException();
235 public void setValue(String name, double value) {
236 throw new UnsupportedOperationException();
242 public void setValue(String name, float value) {
243 throw new UnsupportedOperationException();
249 public void setValue(String name, int value) {
250 throw new UnsupportedOperationException();
256 public void setValue(String name, long value) {
257 throw new UnsupportedOperationException();
263 public void setValue(String name, String value) {
264 throw new UnsupportedOperationException();
270 public void setValue(String name, boolean value) {
271 throw new UnsupportedOperationException();