Package org.eclipse.handly.ui.preference
Class AbstractPreference
- java.lang.Object
-
- org.eclipse.handly.ui.preference.AbstractPreference
-
- All Implemented Interfaces:
IPreference
- Direct Known Subclasses:
BooleanPreference
,DoublePreference
,FloatPreference
,IntPreference
,LongPreference
,StringPreference
public abstract class AbstractPreference extends java.lang.Object implements IPreference
An abstract base implementation of a preference. The preference is stored in anIPreferenceStore
.- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Constructor Summary
Constructors Constructor Description AbstractPreference(java.lang.String name, org.eclipse.jface.preference.IPreferenceStore store)
Creates a new preference with the given name and the given store.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(IPreferenceListener listener)
Adds the given listener for value change events to this preference.java.lang.String
getName()
Returns the name of this preference.org.eclipse.jface.preference.IPreferenceStore
getStore()
Returns the store for this preference.boolean
isDefault()
Returns whether the current value of this preference has the default value.void
removeListener(IPreferenceListener listener)
Removes the given value change listener from this preference.void
setToDefault()
Sets the current value of this preference back to its default value.
-
-
-
Method Detail
-
getName
public final java.lang.String getName()
Returns the name of this preference.- Returns:
- the preference name (never
null
)
-
getStore
public final org.eclipse.jface.preference.IPreferenceStore getStore()
Returns the store for this preference.- Returns:
- the preference store (never
null
)
-
setToDefault
public final void setToDefault()
Sets the current value of this preference back to its default value.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 preference value from the store, thereby exposing the default value.
-
isDefault
public final boolean isDefault()
Returns whether the current value of this preference has the default value.- Returns:
true
if the preference has a known default value and its current value is the same, andfalse
otherwise
-
addListener
public final void addListener(IPreferenceListener listener)
Description copied from interface:IPreference
Adds the given listener for value change events to this preference. Has no effect if the listener is already registered.Make sure to remove the listener on the same preference instance.
- Specified by:
addListener
in interfaceIPreference
- Parameters:
listener
- notnull
-
removeListener
public final void removeListener(IPreferenceListener listener)
Description copied from interface:IPreference
Removes the given value change listener from this preference. Has no effect if the listener was not already registered.- Specified by:
removeListener
in interfaceIPreference
- Parameters:
listener
- notnull
-
-