Class ScopedPreferenceStore
- All Implemented Interfaces:
org.eclipse.jface.preference.IPersistentPreferenceStore
,org.eclipse.jface.preference.IPreferenceStore
org.eclipse.ui.preferences.ScopedPreferenceStore
to fix the memory leak issue described in
Bug 239033.
The ScopedPreferenceStore is an IPreferenceStore that uses the scopes provided in org.eclipse.core.runtime.preferences.
A ScopedPreferenceStore does the lookup of a preference based on its search scopes and sets the value of the preference based on its store scope.
The default scope is always included in the search scopes when searching for preference values.
-
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
ConstructorDescriptionScopedPreferenceStore
(org.eclipse.core.runtime.preferences.IScopeContext context, String qualifier) Creates a new scoped preference store that will store values in the node looked up in the given context by the given qualifier.ScopedPreferenceStore
(org.eclipse.core.runtime.preferences.IScopeContext context, String qualifier, String defaultQualifierPath) Creates a new scoped preference store that will store values in the node looked up in the given context by the given qualifier. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(org.eclipse.jface.util.IPropertyChangeListener listener) boolean
void
firePropertyChangeEvent
(String name, Object oldValue, Object newValue) boolean
getBoolean
(String name) boolean
getDefaultBoolean
(String name) double
getDefaultDouble
(String name) float
getDefaultFloat
(String name) int
getDefaultInt
(String name) long
getDefaultLong
(String name) getDefaultString
(String name) double
float
int
long
org.eclipse.core.runtime.preferences.IEclipsePreferences[]
getPreferenceNodes
(boolean includeDefault) Return the preference path to search preferences on.boolean
boolean
void
void
removePropertyChangeListener
(org.eclipse.jface.util.IPropertyChangeListener listener) void
save()
void
setDefault
(String name, boolean value) void
setDefault
(String name, double value) void
setDefault
(String name, float value) void
setDefault
(String name, int value) void
setDefault
(String name, long value) void
setDefault
(String name, String defaultObject) void
setSearchContexts
(org.eclipse.core.runtime.preferences.IScopeContext[] scopes) Set the search contexts to scopes.void
setToDefault
(String name) void
void
void
void
void
void
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
ScopedPreferenceStore
public ScopedPreferenceStore(org.eclipse.core.runtime.preferences.IScopeContext context, String qualifier, String defaultQualifierPath) Creates a new scoped preference store that will store values in the node looked up in the given context by the given qualifier.- Parameters:
context
- the scope to store toqualifier
- the qualifier used to look up the preference nodedefaultQualifierPath
- the qualifier used when looking up the defaults
-
ScopedPreferenceStore
public ScopedPreferenceStore(org.eclipse.core.runtime.preferences.IScopeContext context, String qualifier) Creates a new scoped preference store that will store values in the node looked up in the given context by the given qualifier.- Parameters:
context
- the scope to store toqualifier
- the qualifier used to look up the preference node
-
-
Method Details
-
setSearchContexts
public void setSearchContexts(org.eclipse.core.runtime.preferences.IScopeContext[] scopes) Set the search contexts to scopes. When searching for a value the search will be done in the order of scope contexts and will not search the storeContext unless it is in this list.If the given list is
null
, then clear this store's search contexts. This means that only this store's scope context and default scope will be used during preference value searching.The defaultContext will be added to the end of this list automatically and MUST NOT be included by the user.
- Parameters:
scopes
- a list of scope contexts to use when searching, ornull
-
getPreferenceNodes
public org.eclipse.core.runtime.preferences.IEclipsePreferences[] getPreferenceNodes(boolean includeDefault) Return the preference path to search preferences on. This is the list of preference nodes based on the scope contexts for this store. If there are no search contexts set, then return this store's context.Whether or not the default context should be included in the resulting list is specified by the
includeDefault
parameter.- Parameters:
includeDefault
-true
if the default context should be included andfalse
otherwise- Returns:
- IEclipsePreferences[]
-
addPropertyChangeListener
public void addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener) - Specified by:
addPropertyChangeListener
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
contains
- Specified by:
contains
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
firePropertyChangeEvent
- Specified by:
firePropertyChangeEvent
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getBoolean
- Specified by:
getBoolean
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDefaultBoolean
- Specified by:
getDefaultBoolean
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDefaultDouble
- Specified by:
getDefaultDouble
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDefaultFloat
- Specified by:
getDefaultFloat
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDefaultInt
- Specified by:
getDefaultInt
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDefaultLong
- Specified by:
getDefaultLong
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDefaultString
- Specified by:
getDefaultString
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getDouble
- Specified by:
getDouble
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getFloat
- Specified by:
getFloat
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getInt
- Specified by:
getInt
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getLong
- Specified by:
getLong
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
getString
- Specified by:
getString
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
isDefault
- Specified by:
isDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
needsSaving
public boolean needsSaving()- Specified by:
needsSaving
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
putValue
- Specified by:
putValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
removePropertyChangeListener
public void removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener) - Specified by:
removePropertyChangeListener
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setDefault
- Specified by:
setDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setDefault
- Specified by:
setDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setDefault
- Specified by:
setDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setDefault
- Specified by:
setDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setDefault
- Specified by:
setDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setDefault
- Specified by:
setDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setToDefault
- Specified by:
setToDefault
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setValue
- Specified by:
setValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setValue
- Specified by:
setValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setValue
- Specified by:
setValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setValue
- Specified by:
setValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setValue
- Specified by:
setValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
setValue
- Specified by:
setValue
in interfaceorg.eclipse.jface.preference.IPreferenceStore
-
save
- Specified by:
save
in interfaceorg.eclipse.jface.preference.IPersistentPreferenceStore
- Throws:
IOException
-