org.eclipse.xtext.ui.editor.preferences
Class FixedScopedPreferenceStore

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore
All Implemented Interfaces:
org.eclipse.jface.preference.IPersistentPreferenceStore, org.eclipse.jface.preference.IPreferenceStore

public class FixedScopedPreferenceStore
extends org.eclipse.core.commands.common.EventManager
implements org.eclipse.jface.preference.IPersistentPreferenceStore

Mainly copied from ScopedPreferenceStore. It fixes the memory leek described in these bugs. The FixedScopedPreferenceStore is an IPreferenceStore that uses the scopes provided in org.eclipse.core.runtime.preferences.

A FixedScopedPreferenceStore does the lookup of a preference based on it's 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.

Since:
2.3
See Also:
ScopedPreferenceStore

Field Summary
protected  boolean silentRunning
          A boolean to indicate the property changes should not be propagated.
 
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
FixedScopedPreferenceStore(org.eclipse.core.runtime.preferences.IScopeContext context, java.lang.String qualifier)
          Create a new instance of the receiver.
FixedScopedPreferenceStore(org.eclipse.core.runtime.preferences.IScopeContext context, java.lang.String qualifier, java.lang.String defaultQualifierPath)
          Create a new instance of the receiver.
 
Method Summary
 void addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
           
 boolean contains(java.lang.String name)
           
 void firePropertyChangeEvent(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
           
 boolean getBoolean(java.lang.String name)
           
 boolean getDefaultBoolean(java.lang.String name)
           
 double getDefaultDouble(java.lang.String name)
           
 float getDefaultFloat(java.lang.String name)
           
 int getDefaultInt(java.lang.String name)
           
 long getDefaultLong(java.lang.String name)
           
 java.lang.String getDefaultString(java.lang.String name)
           
 double getDouble(java.lang.String name)
           
 float getFloat(java.lang.String name)
           
 int getInt(java.lang.String name)
           
 long getLong(java.lang.String name)
           
 org.eclipse.core.runtime.preferences.IEclipsePreferences[] getPreferenceNodes(boolean includeDefault)
          Return the preference path to search preferences on.
 java.lang.String getString(java.lang.String name)
           
 boolean isDefault(java.lang.String name)
           
 boolean needsSaving()
           
 void putValue(java.lang.String name, java.lang.String value)
           
 void removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
           
 void save()
           
 void setDefault(java.lang.String name, boolean value)
           
 void setDefault(java.lang.String name, double value)
           
 void setDefault(java.lang.String name, float value)
           
 void setDefault(java.lang.String name, int value)
           
 void setDefault(java.lang.String name, long value)
           
 void setDefault(java.lang.String name, java.lang.String defaultObject)
           
 void setSearchContexts(org.eclipse.core.runtime.preferences.IScopeContext[] scopes)
          Set the search contexts to scopes.
 void setToDefault(java.lang.String name)
           
 void setValue(java.lang.String name, boolean value)
           
 void setValue(java.lang.String name, double value)
           
 void setValue(java.lang.String name, float value)
           
 void setValue(java.lang.String name, int value)
           
 void setValue(java.lang.String name, long value)
           
 void setValue(java.lang.String name, java.lang.String value)
           
 
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

silentRunning

protected boolean silentRunning
A boolean to indicate the property changes should not be propagated.

Constructor Detail

FixedScopedPreferenceStore

public FixedScopedPreferenceStore(org.eclipse.core.runtime.preferences.IScopeContext context,
                                  java.lang.String qualifier,
                                  java.lang.String defaultQualifierPath)
Create a new instance of the receiver. Store the values in context in the node looked up by qualifier.

Parameters:
context - the scope to store to
qualifier - the qualifier used to look up the preference node
defaultQualifierPath - the qualifier used when looking up the defaults

FixedScopedPreferenceStore

public FixedScopedPreferenceStore(org.eclipse.core.runtime.preferences.IScopeContext context,
                                  java.lang.String qualifier)
Create a new instance of the receiver. Store the values in context in the node looked up by qualifier.

Parameters:
context - the scope to store to
qualifier - the qualifer used to look up the preference node
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface org.eclipse.jface.preference.IPreferenceStore

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 and false otherwise
Returns:
IEclipsePreferences[]
Since:
3.4 public, was added in 3.1 as private method

setSearchContexts

public void setSearchContexts(org.eclipse.core.runtime.preferences.IScopeContext[] scopes)
Set the search contexts to scopes. When searching for a value the seach 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, or null

contains

public boolean contains(java.lang.String name)
Specified by:
contains in interface org.eclipse.jface.preference.IPreferenceStore

firePropertyChangeEvent

public void firePropertyChangeEvent(java.lang.String name,
                                    java.lang.Object oldValue,
                                    java.lang.Object newValue)
Specified by:
firePropertyChangeEvent in interface org.eclipse.jface.preference.IPreferenceStore

getBoolean

public boolean getBoolean(java.lang.String name)
Specified by:
getBoolean in interface org.eclipse.jface.preference.IPreferenceStore

getDefaultBoolean

public boolean getDefaultBoolean(java.lang.String name)
Specified by:
getDefaultBoolean in interface org.eclipse.jface.preference.IPreferenceStore

getDefaultDouble

public double getDefaultDouble(java.lang.String name)
Specified by:
getDefaultDouble in interface org.eclipse.jface.preference.IPreferenceStore

getDefaultFloat

public float getDefaultFloat(java.lang.String name)
Specified by:
getDefaultFloat in interface org.eclipse.jface.preference.IPreferenceStore

getDefaultInt

public int getDefaultInt(java.lang.String name)
Specified by:
getDefaultInt in interface org.eclipse.jface.preference.IPreferenceStore

getDefaultLong

public long getDefaultLong(java.lang.String name)
Specified by:
getDefaultLong in interface org.eclipse.jface.preference.IPreferenceStore

getDefaultString

public java.lang.String getDefaultString(java.lang.String name)
Specified by:
getDefaultString in interface org.eclipse.jface.preference.IPreferenceStore

getDouble

public double getDouble(java.lang.String name)
Specified by:
getDouble in interface org.eclipse.jface.preference.IPreferenceStore

getFloat

public float getFloat(java.lang.String name)
Specified by:
getFloat in interface org.eclipse.jface.preference.IPreferenceStore

getInt

public int getInt(java.lang.String name)
Specified by:
getInt in interface org.eclipse.jface.preference.IPreferenceStore

getLong

public long getLong(java.lang.String name)
Specified by:
getLong in interface org.eclipse.jface.preference.IPreferenceStore

getString

public java.lang.String getString(java.lang.String name)
Specified by:
getString in interface org.eclipse.jface.preference.IPreferenceStore

isDefault

public boolean isDefault(java.lang.String name)
Specified by:
isDefault in interface org.eclipse.jface.preference.IPreferenceStore

needsSaving

public boolean needsSaving()
Specified by:
needsSaving in interface org.eclipse.jface.preference.IPreferenceStore

putValue

public void putValue(java.lang.String name,
                     java.lang.String value)
Specified by:
putValue in interface org.eclipse.jface.preference.IPreferenceStore

removePropertyChangeListener

public void removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface org.eclipse.jface.preference.IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       double value)
Specified by:
setDefault in interface org.eclipse.jface.preference.IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       float value)
Specified by:
setDefault in interface org.eclipse.jface.preference.IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       int value)
Specified by:
setDefault in interface org.eclipse.jface.preference.IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       long value)
Specified by:
setDefault in interface org.eclipse.jface.preference.IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       java.lang.String defaultObject)
Specified by:
setDefault in interface org.eclipse.jface.preference.IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       boolean value)
Specified by:
setDefault in interface org.eclipse.jface.preference.IPreferenceStore

setToDefault

public void setToDefault(java.lang.String name)
Specified by:
setToDefault in interface org.eclipse.jface.preference.IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     double value)
Specified by:
setValue in interface org.eclipse.jface.preference.IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     float value)
Specified by:
setValue in interface org.eclipse.jface.preference.IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     int value)
Specified by:
setValue in interface org.eclipse.jface.preference.IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     long value)
Specified by:
setValue in interface org.eclipse.jface.preference.IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     java.lang.String value)
Specified by:
setValue in interface org.eclipse.jface.preference.IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     boolean value)
Specified by:
setValue in interface org.eclipse.jface.preference.IPreferenceStore

save

public void save()
          throws java.io.IOException
Specified by:
save in interface org.eclipse.jface.preference.IPersistentPreferenceStore
Throws:
java.io.IOException