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 Object implements IPreference
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

    Constructors
    Constructor
    Description
    AbstractPreference(String name, org.eclipse.jface.preference.IPreferenceStore store)
    Creates a new preference with the given name and the given store.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Adds the given listener for value change events to this preference.
    final String
    Returns the name of this preference.
    final org.eclipse.jface.preference.IPreferenceStore
    Returns the store for this preference.
    final boolean
    Returns whether the current value of this preference has the default value.
    final void
    Removes the given value change listener from this preference.
    final void
    Sets the current value of this preference back to its default value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractPreference

      public AbstractPreference(String name, org.eclipse.jface.preference.IPreferenceStore store)
      Creates a new preference with the given name and the given store.
      Parameters:
      name - the preference name (not null)
      store - the preference store (not null)
  • Method Details

    • getName

      public final 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, and false 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 interface IPreference
      Parameters:
      listener - not null
    • 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 interface IPreference
      Parameters:
      listener - not null