Class DefaultScope

  • All Implemented Interfaces:
    IScopeContext

    public final class DefaultScope
    extends org.eclipse.core.internal.preferences.AbstractScope
    Object representing the default scope in the Eclipse preferences hierarchy. Can be used as a context for searching for preference values (in the IPreferencesService APIs) or for determining the correct preference node to set values in the store.

    Default preferences are not persisted to disk.

    The path for preferences defined in the default scope hierarchy is as follows: /default/<qualifier>

    Note about product preference customization: Clients who define their own org.eclipse.core.runtime.IProduct are able to specify a product key of "preferenceCustomization". (defined as a constant in org.eclipse.ui.branding.IProductConstants) Its value is either a URL or a file-system path to a file whose contents are used to customize default preferences.

    This class is not intended to be subclassed. This class may be instantiated.

    Since:
    3.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static IScopeContext INSTANCE
      Singleton instance of a Default Scope object.
      static String SCOPE
      String constant (value of "default") used for the scope name for the default preference scope.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultScope()
      Deprecated.
      use DefaultScope.INSTANCE instead
    • Field Detail

      • SCOPE

        public static final String SCOPE
        String constant (value of "default") used for the scope name for the default preference scope.
        See Also:
        Constant Field Values
      • INSTANCE

        public static final IScopeContext INSTANCE
        Singleton instance of a Default Scope object. Typical usage is: DefaultScope.INSTANCE.getNode(...);
        Since:
        3.4
    • Constructor Detail

      • DefaultScope

        public DefaultScope()
        Deprecated.
        use DefaultScope.INSTANCE instead
        Create and return a new default scope instance.
    • Method Detail

      • getName

        public String getName()
        Description copied from interface: IScopeContext
        Return the name of the scope that this context is associated with. Must not be null.
        Specified by:
        getName in interface IScopeContext
        Specified by:
        getName in class org.eclipse.core.internal.preferences.AbstractScope
        Returns:
        the name of the scope
      • getNode

        public IEclipsePreferences getNode​(String qualifier)
        Description copied from interface: IScopeContext
        Return the preferences node that contains the preferences for the given qualifier or null if the node cannot be determined. The given qualifier must not be null but may be a path to a sub-node within the scope.

        An example of a qualifier in Eclipse 2.1 would be the plug-in identifier that the preference is associated with (e.g. the "org.eclipse.core.resources" plug-in defines the "description.autobuild" preference).

        This method can be used to determine the appropriate preferences node to aid in setting key/value pairs. For instance: new InstanceScope().getNode("org.eclipse.core.resources"); returns the preference node in the instance scope where the preferences for "org.eclipse.core.resources" are stored.

        Specified by:
        getNode in interface IScopeContext
        Overrides:
        getNode in class org.eclipse.core.internal.preferences.AbstractScope
        Parameters:
        qualifier - a qualifier for the preference name
        Returns:
        the node containing the plug-in preferences or null
        See Also:
        IPreferencesService
      • getLocation

        public IPath getLocation()
        Description copied from interface: IScopeContext
        Return a path to a location in the file-system where clients are able to write files that will have the same sharing/scope properties as preferences defined in this scope.

        Implementors may return null if the location is not known, is unavailable, or is not applicable to this scope.

        Specified by:
        getLocation in interface IScopeContext
        Specified by:
        getLocation in class org.eclipse.core.internal.preferences.AbstractScope
        Returns:
        a writable location in the file system or null