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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.internal.ui.preferences;
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;
20 * Mockup preference store, for registering listeners and firing events, without
21 * being an actual store.
23 * All methods except firing, adding and removing listeners throw an
24 * {@link java.lang.UnsupportedOperationException}.
29 public class MockupPreferenceStore implements IPreferenceStore {
31 /** Listeners on this store */
32 private ListenerList fListeners = new ListenerList();
37 public void addPropertyChangeListener(IPropertyChangeListener listener) {
38 fListeners.add(listener);
44 public void removePropertyChangeListener(IPropertyChangeListener listener) {
45 fListeners.remove(listener);
51 public boolean contains(String name) {
52 throw new UnsupportedOperationException();
58 public void firePropertyChangeEvent(String name, Object oldValue,
60 firePropertyChangeEvent(this, name, oldValue, newValue);
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.
73 * The property's old value
75 * The property's new value
77 public void firePropertyChangeEvent(Object source, String name,
78 Object oldValue, Object newValue) {
79 PropertyChangeEvent event = new PropertyChangeEvent(source, name,
81 Object[] listeners = fListeners.getListeners();
82 for (int i = 0; i < listeners.length; i++)
83 ((IPropertyChangeListener) listeners[i]).propertyChange(event);
89 public boolean getBoolean(String name) {
90 throw new UnsupportedOperationException();
96 public boolean getDefaultBoolean(String name) {
97 throw new UnsupportedOperationException();
103 public double getDefaultDouble(String name) {
104 throw new UnsupportedOperationException();
110 public float getDefaultFloat(String name) {
111 throw new UnsupportedOperationException();
117 public int getDefaultInt(String name) {
118 throw new UnsupportedOperationException();
124 public long getDefaultLong(String name) {
125 throw new UnsupportedOperationException();
131 public String getDefaultString(String name) {
132 throw new UnsupportedOperationException();
138 public double getDouble(String name) {
139 throw new UnsupportedOperationException();
145 public float getFloat(String name) {
146 throw new UnsupportedOperationException();
152 public int getInt(String name) {
153 throw new UnsupportedOperationException();
159 public long getLong(String name) {
160 throw new UnsupportedOperationException();
166 public String getString(String name) {
167 throw new UnsupportedOperationException();
173 public boolean isDefault(String name) {
174 throw new UnsupportedOperationException();
180 public boolean needsSaving() {
181 throw new UnsupportedOperationException();
187 public void putValue(String name, String value) {
188 throw new UnsupportedOperationException();
194 public void setDefault(String name, double value) {
195 throw new UnsupportedOperationException();
201 public void setDefault(String name, float value) {
202 throw new UnsupportedOperationException();
208 public void setDefault(String name, int value) {
209 throw new UnsupportedOperationException();
215 public void setDefault(String name, long value) {
216 throw new UnsupportedOperationException();
222 public void setDefault(String name, String defaultObject) {
223 throw new UnsupportedOperationException();
229 public void setDefault(String name, boolean value) {
230 throw new UnsupportedOperationException();
236 public void setToDefault(String name) {
237 throw new UnsupportedOperationException();
243 public void setValue(String name, double value) {
244 throw new UnsupportedOperationException();
250 public void setValue(String name, float value) {
251 throw new UnsupportedOperationException();
257 public void setValue(String name, int value) {
258 throw new UnsupportedOperationException();
264 public void setValue(String name, long value) {
265 throw new UnsupportedOperationException();
271 public void setValue(String name, String value) {
272 throw new UnsupportedOperationException();
278 public void setValue(String name, boolean value) {
279 throw new UnsupportedOperationException();