|
Eclipse Platform 2.0 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.eclipse.jface.preference.PreferenceStore
A concrete preference store implementation based on an internal
java.util.Properties object, with support for
persisting the non-default preference values to files or streams.
This class was not designed to be subclassed.
IPreferenceStore| Field Summary |
| Fields inherited from interface org.eclipse.jface.preference.IPreferenceStore |
BOOLEAN_DEFAULT_DEFAULT, DOUBLE_DEFAULT_DEFAULT, FALSE, FLOAT_DEFAULT_DEFAULT, INT_DEFAULT_DEFAULT, LONG_DEFAULT_DEFAULT, STRING_DEFAULT_DEFAULT, TRUE |
| Constructor Summary | |
PreferenceStore()
Creates an empty preference store. |
|
PreferenceStore(String filename)
Creates an empty preference store that loads from and saves to the a file. |
|
| Method Summary | |
void |
addPropertyChangeListener(IPropertyChangeListener listener)
Adds a property change listener to this preference store. |
boolean |
contains(String name)
Returns whether the named preference is known to this preference store. |
void |
firePropertyChangeEvent(String name,
Object oldValue,
Object newValue)
Fires a property change event corresponding to a change to the current value of the preference with the given name. |
boolean |
getBoolean(String name)
Returns the current value of the boolean-valued preference with the given name. |
boolean |
getDefaultBoolean(String name)
Returns the default value for the boolean-valued preference with the given name. |
double |
getDefaultDouble(String name)
Returns the default value for the double-valued preference with the given name. |
float |
getDefaultFloat(String name)
Returns the default value for the float-valued preference with the given name. |
int |
getDefaultInt(String name)
Returns the default value for the integer-valued preference with the given name. |
long |
getDefaultLong(String name)
Returns the default value for the long-valued preference with the given name. |
String |
getDefaultString(String name)
Returns the default value for the string-valued preference with the given name. |
double |
getDouble(String name)
Returns the current value of the double-valued preference with the given name. |
float |
getFloat(String name)
Returns the current value of the float-valued preference with the given name. |
int |
getInt(String name)
Returns the current value of the integer-valued preference with the given name. |
long |
getLong(String name)
Returns the current value of the long-valued preference with the given name. |
String |
getString(String name)
Returns the current value of the string-valued preference with the given name. |
boolean |
isDefault(String name)
Returns whether the current value of the preference with the given name has the default value. |
void |
list(PrintStream out)
Prints the contents of this preference store to the given print stream. |
void |
list(PrintWriter out)
Prints the contents of this preference store to the given print writer. |
void |
load()
Loads this preference store from the file established in the constructor PreferenceStore(java.lang.String) (or by setFileName). |
void |
load(InputStream in)
Loads this preference store from the given input stream. |
boolean |
needsSaving()
Returns whether the current values in this property store require saving. |
String[] |
preferenceNames()
Returns an enumeration of all preferences known to this store which have current values other than their default value. |
void |
putValue(String name,
String value)
Sets the current value of the preference with the given name to the given string value. |
void |
removePropertyChangeListener(IPropertyChangeListener listener)
Removes the given listener from this preference store. |
void |
save()
Saves the non-default-valued preferences known to this preference store to the file from which they were originally loaded. |
void |
save(OutputStream out,
String header)
Saves this preference store to the given output stream. |
void |
setDefault(String name,
boolean value)
Sets the default value for the boolean-valued preference with the given name. |
void |
setDefault(String name,
double value)
Sets the default value for the double-valued preference with the given name. |
void |
setDefault(String name,
float value)
Sets the default value for the float-valued preference with the given name. |
void |
setDefault(String name,
int value)
Sets the default value for the integer-valued preference with the given name. |
void |
setDefault(String name,
long value)
Sets the default value for the long-valued preference with the given name. |
void |
setDefault(String name,
String value)
Sets the default value for the string-valued preference with the given name. |
void |
setFilename(String name)
Sets the name of the file used when loading and storing this preference store. |
void |
setToDefault(String name)
Sets the current value of the preference with the given name back to its default value. |
void |
setValue(String name,
boolean value)
Sets the current value of the boolean-valued preference with the given name. |
void |
setValue(String name,
double value)
Sets the current value of the double-valued preference with the given name. |
void |
setValue(String name,
float value)
Sets the current value of the float-valued preference with the given name. |
void |
setValue(String name,
int value)
Sets the current value of the integer-valued preference with the given name. |
void |
setValue(String name,
long value)
Sets the current value of the long-valued preference with the given name. |
void |
setValue(String name,
String value)
Sets the current value of the string-valued preference with the given name. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PreferenceStore()
Use the methods load(InputStream) and
save(InputStream) to load and store this
preference store.
load(java.io.InputStream),
#store(java.io.InputStream)public PreferenceStore(String filename)
Use the methods load() and save() to load and store this
preference store.
filename - the file nameload(),
#store()| Method Detail |
public void addPropertyChangeListener(IPropertyChangeListener listener)
IPreferenceStore
addPropertyChangeListener in interface IPreferenceStorelistener - a property change listenerpublic boolean contains(String name)
IPreferenceStore
contains in interface IPreferenceStorename - the name of the preference
true if either a current value or a default
value is known for the named preference, and falseotherwise
public void firePropertyChangeEvent(String name,
Object oldValue,
Object newValue)
IPreferenceStore
This method is provided on this interface to simplify the implementation
of decorators. There is normally no need to call this method since
setValue and setToDefault report such
events in due course. Implementations should funnel all preference
changes through this method.
firePropertyChangeEvent in interface IPreferenceStorename - the name of the preference, to be used as the property
in the event objectoldValue - the old valuenewValue - the new valuepublic boolean getBoolean(String name)
IPreferenceStorefalse) if there
is no preference with the given name, or if the current value
cannot be treated as a boolean.
getBoolean in interface IPreferenceStorename - the name of the preference
public boolean getDefaultBoolean(String name)
IPreferenceStorefalse) if there
is no default preference with the given name, or if the default
value cannot be treated as a boolean.
getDefaultBoolean in interface IPreferenceStorename - the name of the preference
public double getDefaultDouble(String name)
IPreferenceStore0.0) if there
is no default preference with the given name, or if the default
value cannot be treated as a double.
getDefaultDouble in interface IPreferenceStorename - the name of the preference
public float getDefaultFloat(String name)
IPreferenceStore0.0f) if there
is no default preference with the given name, or if the default
value cannot be treated as a float.
getDefaultFloat in interface IPreferenceStorename - the name of the preference
public int getDefaultInt(String name)
IPreferenceStore0) if there
is no default preference with the given name, or if the default
value cannot be treated as an integer.
getDefaultInt in interface IPreferenceStorename - the name of the preference
public long getDefaultLong(String name)
IPreferenceStore0L) if there
is no default preference with the given name, or if the default
value cannot be treated as a long.
getDefaultLong in interface IPreferenceStorename - the name of the preference
public String getDefaultString(String name)
IPreferenceStore"")
is no default preference with the given name, or if the default
value cannot be treated as a string.
getDefaultString in interface IPreferenceStorename - the name of the preference
public double getDouble(String name)
IPreferenceStore0.0) if there
is no preference with the given name, or if the current value
cannot be treated as a double.
getDouble in interface IPreferenceStorename - the name of the preference
public float getFloat(String name)
IPreferenceStore0.0f) if there
is no preference with the given name, or if the current value
cannot be treated as a float.
getFloat in interface IPreferenceStorename - the name of the preference
public int getInt(String name)
IPreferenceStore0) if there
is no preference with the given name, or if the current value
cannot be treated as an integter.
getInt in interface IPreferenceStorename - the name of the preference
public long getLong(String name)
IPreferenceStore0L) if there
is no preference with the given name, or if the current value
cannot be treated as a long.
getLong in interface IPreferenceStorename - the name of the preference
public String getString(String name)
IPreferenceStore"")
if there is no preference with the given name, or if the current value
cannot be treated as a string.
getString in interface IPreferenceStorename - the name of the preference
public boolean isDefault(String name)
IPreferenceStore
isDefault in interface IPreferenceStorename - the name of the preference
true if the preference has a known default value
and its current value is the same, and false otherwise
(including the case where the preference is unknown to this store)public void list(PrintStream out)
out - the print streampublic void list(PrintWriter out)
out - the print writer
public void load()
throws IOException
PreferenceStore(java.lang.String) (or by setFileName).
Default preference values are not affected.
IOException - if there is a problem loading this store
public void load(InputStream in)
throws IOException
in - the input stream
IOException - if there is a problem loading this storepublic boolean needsSaving()
IPreferenceStore
needsSaving in interface IPreferenceStoretrue if at least one of the preferences
known to this store has a current value different from its
default value, and false otherwisepublic String[] preferenceNames()
public void putValue(String name,
String value)
IPreferenceStore
This method is provided on this interface to simplify the implementation
of decorators, and does not report a property change event.
Normal clients should instead call setValue.
putValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preferencepublic void removePropertyChangeListener(IPropertyChangeListener listener)
IPreferenceStore
removePropertyChangeListener in interface IPreferenceStorelistener - a property change listener
public void save()
throws IOException
IOException - if there is a problem saving this store
public void save(OutputStream out,
String header)
throws IOException
out - the output streamheader - the header
IOException - if there is a problem saving this store
public void setDefault(String name,
double value)
IPreferenceStoreNote that the current value of the preference is affected if the preference's current value was its old default value, in which case it changes to the new default value. If the preference's current is different from its old default value, its current value is unaffected. No property change events are reported by changing default values.
setDefault in interface IPreferenceStorename - the name of the preferencevalue - the new default value for the preference
public void setDefault(String name,
float value)
IPreferenceStoreNote that the current value of the preference is affected if the preference's current value was its old default value, in which case it changes to the new default value. If the preference's current is different from its old default value, its current value is unaffected. No property change events are reported by changing default values.
setDefault in interface IPreferenceStorename - the name of the preferencevalue - the new default value for the preference
public void setDefault(String name,
int value)
IPreferenceStoreNote that the current value of the preference is affected if the preference's current value was its old default value, in which case it changes to the new default value. If the preference's current is different from its old default value, its current value is unaffected. No property change events are reported by changing default values.
setDefault in interface IPreferenceStorename - the name of the preferencevalue - the new default value for the preference
public void setDefault(String name,
long value)
IPreferenceStoreNote that the current value of the preference is affected if the preference's current value was its old default value, in which case it changes to the new default value. If the preference's current is different from its old default value, its current value is unaffected. No property change events are reported by changing default values.
setDefault in interface IPreferenceStorename - the name of the preferencevalue - the new default value for the preference
public void setDefault(String name,
String value)
IPreferenceStoreNote that the current value of the preference is affected if the preference's current value was its old default value, in which case it changes to the new default value. If the preference's current is different from its old default value, its current value is unaffected. No property change events are reported by changing default values.
setDefault in interface IPreferenceStorename - the name of the preference
public void setDefault(String name,
boolean value)
IPreferenceStoreNote that the current value of the preference is affected if the preference's current value was its old default value, in which case it changes to the new default value. If the preference's current is different from its old default value, its current value is unaffected. No property change events are reported by changing default values.
setDefault in interface IPreferenceStorename - the name of the preferencevalue - the new default value for the preferencepublic void setFilename(String name)
Afterward, the methods load() and save() can be used
to load and store this preference store.
load(),
#store()public void setToDefault(String name)
IPreferenceStore
Note that the preferred way of re-initializing a preference to the
appropriate default value is to call setToDefault.
This is implemented by removing the named value from the store,
thereby exposing the default value.
setToDefault in interface IPreferenceStorename - the name of the preference
public void setValue(String name,
double value)
IPreferenceStoreA property change event is reported if the current value of the preference actually changes from its previous value. In the event object, the property name is the name of the preference, and the old and new values are wrapped as objects.
Note that the preferred way of re-initializing a preference to its
default value is to call setToDefault.
setValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preference
public void setValue(String name,
float value)
IPreferenceStoreA property change event is reported if the current value of the preference actually changes from its previous value. In the event object, the property name is the name of the preference, and the old and new values are wrapped as objects.
Note that the preferred way of re-initializing a preference to its
default value is to call setToDefault.
setValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preference
public void setValue(String name,
int value)
IPreferenceStoreA property change event is reported if the current value of the preference actually changes from its previous value. In the event object, the property name is the name of the preference, and the old and new values are wrapped as objects.
Note that the preferred way of re-initializing a preference to its
default value is to call setToDefault.
setValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preference
public void setValue(String name,
long value)
IPreferenceStoreA property change event is reported if the current value of the preference actually changes from its previous value. In the event object, the property name is the name of the preference, and the old and new values are wrapped as objects.
Note that the preferred way of re-initializing a preference to its
default value is to call setToDefault.
setValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preference
public void setValue(String name,
String value)
IPreferenceStoreA property change event is reported if the current value of the preference actually changes from its previous value. In the event object, the property name is the name of the preference, and the old and new values are wrapped as objects.
Note that the preferred way of re-initializing a preference to its
default value is to call setToDefault.
setValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preference
public void setValue(String name,
boolean value)
IPreferenceStoreA property change event is reported if the current value of the preference actually changes from its previous value. In the event object, the property name is the name of the preference, and the old and new values are wrapped as objects.
Note that the preferred way of re-initializing a preference to its
default value is to call setToDefault.
setValue in interface IPreferenceStorename - the name of the preferencevalue - the new current value of the preference
|
Eclipse Platform 2.0 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||