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
An abstract base implementation of a preference.
The preference is stored in an
IPreferenceStore
.- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractPreference
(String name, org.eclipse.jface.preference.IPreferenceStore store) Creates a new preference with the given name and the given store. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addListener
(IPreferenceListener listener) Adds the given listener for value change events to this preference.final String
getName()
Returns the name of this preference.final org.eclipse.jface.preference.IPreferenceStore
getStore()
Returns the store for this preference.final boolean
Returns whether the current value of this preference has the default value.final void
removeListener
(IPreferenceListener listener) Removes the given value change listener from this preference.final void
Sets the current value of this preference back to its default value.
-
Constructor Details
-
AbstractPreference
Creates a new preference with the given name and the given store.- Parameters:
name
- the preference name (notnull
)store
- the preference store (notnull
)
-
-
Method Details
-
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
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
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
-