Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "E4/Doc/Preferences"

< E4‎ | Doc
Line 28: Line 28:
  
 
== Implementation ==
 
== Implementation ==
 +
 +
In the most common case, e4 permits preference retrieval through dependency injection.  By specifying an injection with a @Preference qualifier key, the qualifier's corresponding preference value is retrieved and injected. 
 +
 +
For example, in the following Java code,
 +
<source lang="java">
 +
 +
public class LoginWindow
 +
 +
@Inject @Preference(MyPrefConstants.DEFAULT_USERNAME) String username;
 +
 +
public LoginWindow(){
 +
  getUserNameInput.setText(username);
 +
}
 +
 +
</source>

Revision as of 13:13, 16 March 2010

Under Construction: Please read first!

The evolution of this document is a collaborative effort between a team of students at the University of Manitoba and the wider Eclipse community. Details about the project can be found here and on our Blog.

Your input is not just welcome; it is needed! Please contribute as your expertise allows, while adhering to our template. To send your feedback and any questions or comments you may have please email us. Also, while we do our very best to be as accurate and precise as possible, it is worth noting that we are students with limited exposure to the Eclipse platform, so if you see any incorrect technical details please let us know.

Diagram of services in E4.
A placeholder diagram.

The ability for users to customize application features according to their individual requirements is often useful. Eclipse e4 provides a mechanism to persist and retrieve these customizations, known as preferences, within a range of scopes.

In the most common case, a user preference is simply a key-value pair that is associated with an Eclipse instance. For example, the preference that specifies that a user would like to have a tool tip displayed on startup could be stored as "showToolTip=true".

Relevant Terms

  • Key - A key is a unique string identifier for a preference setting.
  • Value - A value is the current preference setting associated with a key, within a specific scope.
  • Eclipse instance - An Eclipse instance is synonymous with a workspace. In the context of preferences, an instance scope is valid while using a specific workspace.

Motivation

Although managing preferences within a variety of scopes can become complex, e4 has streamlined the most common, "80-percent" case. In this default scenario, preferences reside within the scope of an Eclipse instance. This means that when a user switches workspaces, a new set corresponding preferences are applied.

For situations where greater control of preference behaviour is necessary, e4 provides mechanisms to specify a range of scopes and listen for changes to preferences. For example, a user may want to apply a preference to all workspaces within a single Eclipse install, to a plugin or set of plugins, or to a set of projects within a plugin. Eclipse e4 permits this flexibility of scope, and enables cascading preferences through the chaining of scopes in any order.

Applicability

The applications of preferences are many:

  • UI customization: fonts, window & pane properties, and colors
  • Installation settings: locations of resources, working directories
  • Application settings: internationalization selections, program parameters

Implementation

In the most common case, e4 permits preference retrieval through dependency injection. By specifying an injection with a @Preference qualifier key, the qualifier's corresponding preference value is retrieved and injected.

For example, in the following Java code,

public class LoginWindow
 
@Inject @Preference(MyPrefConstants.DEFAULT_USERNAME) String username;
 
public LoginWindow(){
   getUserNameInput.setText(username);
}

Back to the top