Jump to: navigation, search

Difference between revisions of "FAQ What is a preference scope?"

 
m (Fixed bad link to instancescope)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
''
+
The preference service uses the notion of <i>preference scopes</i> to describe the various areas where preferences can be saved.  The platform includes the following preference scopes:
  
 +
* <i>Configuration scope</i>.  Preferences stored in this scope are shared by all workspaces that are launched using a particular configuration of Eclipse plug-ins. On a single-user installation, this serves to capture preferences that are common to all workspaces launched by that user. On a multi-user installation, these preferences are shared by all users of the configuration.
  
 +
* <i>Instance scope</i>.  Preferences in this scope are specific  to a single Eclipse workspace. The old API method <tt>getPluginPreferences</tt>  on <tt>Plugin</tt> stores its preferences at this scope.
  
The preference service uses the notion of <i>preference scopes</i>
+
* <i>Default scope</i>. This scope is not stored on disk at all but can be used to store default values for all your keys.  When values are not found in other scopes, the default scope is consulted last to provide reasonable default values.
to describe the various areas where preferences can be saved.  The
+
platform includes the following four preference scopes:
+
 
+
 
+
* <i>Configuration scope</i>.  Preferences stored in this scope are shared
+
by all workspaces that are launched using a particular configuration
+
of Eclipse plug-ins. On a single-user installation, this serves to capture
+
preferences that are common to all workspaces launched by that user. On
+
a multi-user installation, these preferences are shared by all users of the configuration.</li>
+
 
+
 
+
 
+
 
+
* <i>Instance scope</i>.  Preferences in this scope are specific
+
to a single Eclipse workspace. The old API method <tt>getPluginPreferences</tt>
+
on <tt>Plugin</tt> stores its preferences at this scope.</li>
+
 
+
 
+
 
+
 
+
* <i>Default scope</i>. This scope is not stored on disk at all but can be used
+
to store default values for all your keys.  When values are not found
+
in other scopes, the default scope is consulted last to provide
+
reasonable default values.</li>
+
 
+
 
+
 
+
 
+
* <i>Project scope</i>.  This scope
+
stores values that are specific to a single project in your workspace, such as
+
code formatter and compiler settings. Note that this scope is provided by the
+
<tt>org.eclipse.core.resources</tt> plug-in, which is not included in the Eclipse
+
Rich Client Platform.  This scope will not exist in
+
applications that don&#146;t explicitly include the <tt>resources</tt> plug-in.</li>
+
 
+
 
+
 
+
 
+
 
+
Plug-ins can also define their own preference scopes, using the
+
<tt>org.eclipse.core.runtime.preference</tt> extension point. If you define
+
your own scope, you can control how and where your preferences are
+
loaded and stored.  However, for most clients, the four built in scopes
+
will be sufficient.
+
 
+
  
 +
* ''BundleDefaultsScope''. Similar to the default scope, these values are not written to disk.  They are however read from a particular bundle's "preferences.ini" file.
  
 +
* <i>Project scope</i>.  This scope stores values that are specific to a single project in your workspace, such as code formatter and compiler settings. Note that this scope is provided by the  <tt>org.eclipse.core.resources</tt> plug-in, which is not included in the Eclipse Rich Client Platform.  This scope will not exist in  applications that don&#146;t explicitly include the <tt>resources</tt> plug-in.
  
 +
Plug-ins can also define their own preference scopes, using the  <tt>org.eclipse.core.runtime.preferences</tt> extension point. If you define your own scope, you can control how and where your preferences are loaded and stored.  However, for most clients, the built in scopes will be sufficient.
  
 +
The majority of the above scopes can be addressed programatically with a particular implementation of [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html IScopeContext]:
 +
*<tt>[http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/ConfigurationScope.html ConfigurationScope]</tt>
 +
*<tt>[http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/InstanceScope.html InstanceScope]</tt>
 +
*<tt>[http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/DefaultScope.html DefaultScope]</tt>
 +
*<tt>[http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/IScopeContext.html ProjectScope]</tt>
  
 
== See Also: ==
 
== See Also: ==
 
+
*[[FAQ_What_is_a_configuration%3F]]
 
+
*[[FAQ_How_do_I_use_the_preference_service%3F]]
[[FAQ_What_is_a_configuration%3F]]
+
 
+
 
+
[[FAQ_How_do_I_use_the_preference_service%3F]]
+
  
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>

Latest revision as of 17:49, 1 August 2011

The preference service uses the notion of preference scopes to describe the various areas where preferences can be saved. The platform includes the following preference scopes:

  • Configuration scope. Preferences stored in this scope are shared by all workspaces that are launched using a particular configuration of Eclipse plug-ins. On a single-user installation, this serves to capture preferences that are common to all workspaces launched by that user. On a multi-user installation, these preferences are shared by all users of the configuration.
  • Instance scope. Preferences in this scope are specific to a single Eclipse workspace. The old API method getPluginPreferences on Plugin stores its preferences at this scope.
  • Default scope. This scope is not stored on disk at all but can be used to store default values for all your keys. When values are not found in other scopes, the default scope is consulted last to provide reasonable default values.
  • BundleDefaultsScope. Similar to the default scope, these values are not written to disk. They are however read from a particular bundle's "preferences.ini" file.
  • Project scope. This scope stores values that are specific to a single project in your workspace, such as code formatter and compiler settings. Note that this scope is provided by the org.eclipse.core.resources plug-in, which is not included in the Eclipse Rich Client Platform. This scope will not exist in applications that don’t explicitly include the resources plug-in.

Plug-ins can also define their own preference scopes, using the org.eclipse.core.runtime.preferences extension point. If you define your own scope, you can control how and where your preferences are loaded and stored. However, for most clients, the built in scopes will be sufficient.

The majority of the above scopes can be addressed programatically with a particular implementation of IScopeContext:

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.