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;
17 //import org.eclipse.jface.util.ListenerList;
18 import org.eclipse.core.runtime.ListenerList;
20 import org.eclipse.jface.util.PropertyChangeEvent;
23 * Mockup preference store, for registering listeners and firing events, without
24 * being an actual store.
26 * All methods except firing, adding and removing listeners throw an
27 * {@link java.lang.UnsupportedOperationException}.
32 public class MockupPreferenceStore implements IPreferenceStore {
34 /** Listeners on this store */
35 private ListenerList fListeners = new ListenerList();
40 public void addPropertyChangeListener(IPropertyChangeListener listener) {
41 fListeners.add(listener);
47 public void removePropertyChangeListener(IPropertyChangeListener listener) {
48 fListeners.remove(listener);
54 public boolean contains(String name) {
55 throw new UnsupportedOperationException();
61 public void firePropertyChangeEvent(String name, Object oldValue,
63 firePropertyChangeEvent(this, name, oldValue, newValue);
67 * Fires a property change event with the given source, property name, old
68 * and new value. Used when the event source should be different from this
69 * mockup preference store.
76 * The property's old value
78 * The property's new value
80 public void firePropertyChangeEvent(Object source, String name,
81 Object oldValue, Object newValue) {
82 PropertyChangeEvent event = new PropertyChangeEvent(source, name,
84 Object[] listeners = fListeners.getListeners();
85 for (int i = 0; i < listeners.length; i++)
86 ((IPropertyChangeListener) listeners[i]).propertyChange(event);
92 public boolean getBoolean(String name) {
93 throw new UnsupportedOperationException();
99 public boolean getDefaultBoolean(String name) {
100 throw new UnsupportedOperationException();
106 public double getDefaultDouble(String name) {
107 throw new UnsupportedOperationException();
113 public float getDefaultFloat(String name) {
114 throw new UnsupportedOperationException();
120 public int getDefaultInt(String name) {
121 throw new UnsupportedOperationException();
127 public long getDefaultLong(String name) {
128 throw new UnsupportedOperationException();
134 public String getDefaultString(String name) {
135 throw new UnsupportedOperationException();
141 public double getDouble(String name) {
142 throw new UnsupportedOperationException();
148 public float getFloat(String name) {
149 throw new UnsupportedOperationException();
155 public int getInt(String name) {
156 throw new UnsupportedOperationException();
162 public long getLong(String name) {
163 throw new UnsupportedOperationException();
169 public String getString(String name) {
170 throw new UnsupportedOperationException();
176 public boolean isDefault(String name) {
177 throw new UnsupportedOperationException();
183 public boolean needsSaving() {
184 throw new UnsupportedOperationException();
190 public void putValue(String name, String value) {
191 throw new UnsupportedOperationException();
197 public void setDefault(String name, double value) {
198 throw new UnsupportedOperationException();
204 public void setDefault(String name, float value) {
205 throw new UnsupportedOperationException();
211 public void setDefault(String name, int value) {
212 throw new UnsupportedOperationException();
218 public void setDefault(String name, long value) {
219 throw new UnsupportedOperationException();
225 public void setDefault(String name, String defaultObject) {
226 throw new UnsupportedOperationException();
232 public void setDefault(String name, boolean value) {
233 throw new UnsupportedOperationException();
239 public void setToDefault(String name) {
240 throw new UnsupportedOperationException();
246 public void setValue(String name, double value) {
247 throw new UnsupportedOperationException();
253 public void setValue(String name, float value) {
254 throw new UnsupportedOperationException();
260 public void setValue(String name, int value) {
261 throw new UnsupportedOperationException();
267 public void setValue(String name, long value) {
268 throw new UnsupportedOperationException();
274 public void setValue(String name, String value) {
275 throw new UnsupportedOperationException();
281 public void setValue(String name, boolean value) {
282 throw new UnsupportedOperationException();