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,
21 * without being an actual store.
23 * All methods except firing, adding and removing listeners throw
24 * an {@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, Object newValue) {
59 firePropertyChangeEvent(this, name, oldValue, newValue);
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
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);
80 public boolean getBoolean(String name) {
81 throw new UnsupportedOperationException();
87 public boolean getDefaultBoolean(String name) {
88 throw new UnsupportedOperationException();
94 public double getDefaultDouble(String name) {
95 throw new UnsupportedOperationException();
101 public float getDefaultFloat(String name) {
102 throw new UnsupportedOperationException();
108 public int getDefaultInt(String name) {
109 throw new UnsupportedOperationException();
115 public long getDefaultLong(String name) {
116 throw new UnsupportedOperationException();
122 public String getDefaultString(String name) {
123 throw new UnsupportedOperationException();
129 public double getDouble(String name) {
130 throw new UnsupportedOperationException();
136 public float getFloat(String name) {
137 throw new UnsupportedOperationException();
143 public int getInt(String name) {
144 throw new UnsupportedOperationException();
150 public long getLong(String name) {
151 throw new UnsupportedOperationException();
157 public String getString(String name) {
158 throw new UnsupportedOperationException();
164 public boolean isDefault(String name) {
165 throw new UnsupportedOperationException();
171 public boolean needsSaving() {
172 throw new UnsupportedOperationException();
178 public void putValue(String name, String value) {
179 throw new UnsupportedOperationException();
185 public void setDefault(String name, double value) {
186 throw new UnsupportedOperationException();
192 public void setDefault(String name, float value) {
193 throw new UnsupportedOperationException();
199 public void setDefault(String name, int value) {
200 throw new UnsupportedOperationException();
206 public void setDefault(String name, long value) {
207 throw new UnsupportedOperationException();
213 public void setDefault(String name, String defaultObject) {
214 throw new UnsupportedOperationException();
220 public void setDefault(String name, boolean value) {
221 throw new UnsupportedOperationException();
227 public void setToDefault(String name) {
228 throw new UnsupportedOperationException();
234 public void setValue(String name, double value) {
235 throw new UnsupportedOperationException();
241 public void setValue(String name, float value) {
242 throw new UnsupportedOperationException();
248 public void setValue(String name, int value) {
249 throw new UnsupportedOperationException();
255 public void setValue(String name, long value) {
256 throw new UnsupportedOperationException();
262 public void setValue(String name, String value) {
263 throw new UnsupportedOperationException();
269 public void setValue(String name, boolean value) {
270 throw new UnsupportedOperationException();