public abstract class AbstractProjectPreference<T> extends AbstractEclipsePreference<T> implements IProjectPreference<T>
IProjectPreference
. Provides almost all logic required for being used with a
concrete preference.
Defines two methods, #toObject(String)
and #toString(Object)
, to convert the preference values. These
methods should be overwritten by the subclasses.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
requiredProjectNatureId
Project nature that is required by the preference.
|
defaultValueAsString, key, qualifier
Constructor and Description |
---|
AbstractProjectPreference(java.lang.String requiredProjectNatureId,
java.lang.String qualifier,
java.lang.String key,
java.lang.String defaultValueAsString)
Constructor of the preference.
|
Modifier and Type | Method and Description |
---|---|
void |
addPreferenceChangeListener(org.eclipse.core.resources.IProject project,
org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
Registers the given listener for notification of changes of this preference in specified project.
|
T |
get(org.eclipse.core.resources.IProject project)
Returns the value of the preference.
|
T |
getDefaultValueAsObject(org.eclipse.core.resources.IProject project) |
protected org.eclipse.core.runtime.preferences.IEclipsePreferences |
getProjectPreferences(org.eclipse.core.resources.IProject project)
Get the Eclipse preferences associated with the
project . |
java.lang.String |
getRequiredProjectNatureId()
Return the identifier of the project nature that is required by the preference.
|
void |
removePreferenceChangeListener(org.eclipse.core.resources.IProject project,
org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
Unregisters the given listener from receiving notification of changes of this preference in specified project.
|
void |
set(org.eclipse.core.resources.IProject project,
T valueAsObject)
Set the value of the preference.
|
void |
setToDefault(org.eclipse.core.resources.IProject project) |
protected T |
toObject(org.eclipse.core.resources.IProject project,
java.lang.String valueAsString)
Converts the
valueAsString , that is a possible string value for the preference, into an object
value. |
protected java.lang.String |
toString(org.eclipse.core.resources.IProject project,
T valueAsObject)
Converts the
valueAsObject , that is a possible object value for the preference, into a string value. |
getDefaultValueAsString, getKey, getQualifier
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDefaultValueAsString, getKey, getQualifier
protected java.lang.String requiredProjectNatureId
public AbstractProjectPreference(java.lang.String requiredProjectNatureId, java.lang.String qualifier, java.lang.String key, java.lang.String defaultValueAsString)
requiredProjectNatureId
- the project nature that is required by the preferencequalifier
- the qualifier of the preferencekey
- the key of the preferencedefaultValueAsString
- the default value of the preferenceAbstractEclipsePreference.AbstractEclipsePreference(String, String, String)
public java.lang.String getRequiredProjectNatureId()
IProjectPreference
getRequiredProjectNatureId
in interface IProjectPreference<T>
public T get(org.eclipse.core.resources.IProject project)
IProjectPreference
get
in interface IProjectPreference<T>
project
- the project for which the preference is retrievedIEclipsePreference.getDefaultValueAsString()
public void set(org.eclipse.core.resources.IProject project, T valueAsObject)
IProjectPreference
set
in interface IProjectPreference<T>
project
- the project for which the preference is retrievedvalueAsObject
- the new value of the preferencepublic T getDefaultValueAsObject(org.eclipse.core.resources.IProject project)
getDefaultValueAsObject
in interface IProjectPreference<T>
public void setToDefault(org.eclipse.core.resources.IProject project)
setToDefault
in interface IProjectPreference<T>
public void addPreferenceChangeListener(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
IProjectPreference
null
.addPreferenceChangeListener
in interface IProjectPreference<T>
project
- the project in which the changes of this preference are to be observedlistener
- the preference change listener to register#removePreferenceChangeListener(IEclipsePreferences.IPreferenceChangeListener)
,
IEclipsePreferences.IPreferenceChangeListener
public void removePreferenceChangeListener(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
IProjectPreference
null
.removePreferenceChangeListener
in interface IProjectPreference<T>
project
- the project in which the changes of this preference have been observedlistener
- the preference change listener to remove#addPreferenceChangeListener(IEclipsePreferences.IPreferenceChangeListener)
,
IEclipsePreferences.IPreferenceChangeListener
protected org.eclipse.core.runtime.preferences.IEclipsePreferences getProjectPreferences(org.eclipse.core.resources.IProject project)
project
. project
should not be
null
.project
- the project from which the preferences are retrievedProjectScope.getNode(String)
protected T toObject(org.eclipse.core.resources.IProject project, java.lang.String valueAsString)
valueAsString
, that is a possible string value for the preference, into an object
value. The conversion may depend on the nature of the project
that is provided.
By default this method returns null
. It has to be overwritten by the subclasses.
project
- the project the preference depends onvalueAsString
- string value to be convertedprotected java.lang.String toString(org.eclipse.core.resources.IProject project, T valueAsObject)
valueAsObject
, that is a possible object value for the preference, into a string value.
The conversion may depend on the nature of the project
that is provided.
By default, calls the Object.toString()
method of the object value to perform the conversion. It returns
null
if valueAsObject
is null
. This method may be overwritten by the
subclasses.
project
- the project the preference depends onvalueAsObject
- object value to be converted