Overview
A preference specification (.pfsp) file contains a set of declarations of language-
specific preferences, and is used for three purposes: (1) to generate the appropriate
set of user-interface components that populate the preference pages, (2) to generate
a set of definitions (constants, etc.) that provide access to the current preference
values for clients (e.g. other parts of your IDE), and (3) to generate code that
defines the initial/default values for the language-specific preferences.
The IMP meta-tooling includes a compiler and builder for preference specification
files to generate the aforementioned code when a prefspecs file is modified.
The IMP preferences mechanism can expose all 4 Eclipse-defined levels of
preference settings, which are, in order from most general to most specific:
- Default (hardwired constants in your IDE's code)
- Configuration (one per Eclipse installation)
- Instance (one per workspace instance)
- Project (one per workspace project)
These 4 levels form a hierarchy, with the "default" level at the top.
A value can be specified for a given preference at any or all of these levels.
As indicated above, the value at the "default" level is hard-wired into the
IDE's code, but the values defined at all other levels (if any) are supplied
by the user through the IDE's preference pages.
Likewise, queries can be made programmatically at any level, though typically
clients make queries either at the project level (if, say, the query is
performed in the context of a currently-selected project) or at the "instance"
level.
A value need not be defined at every level for a given preference, and in that
case its value at that level is inherited from the next higher level that does
specify a value. To ensure that a query at any level will always produce a
well-defined value, every preference must be provided with a default value.
[At the same time, it is possible to query the value set at a specific level,
which may be null if that level has no value for the given preference.]
Preferences are (logically) segregated by language; thus, when querying or
setting a preference value, either a default language must be set or a
specific language must be provided to the query.
Preferences are designated by String keys, whose prefix embeds the language
ID, and whose suffix is part of the preference specification.
The IMP Preferences UI
The preference pages generated by the IMP prefspecs compiler have largely the
same look and feel as the pages used by various Eclipse projects (in fact, they
use the same base classes), with one significant difference. The IMP-generated
preference pages by default expose the preference settings at multiple
levels, whereas most "standard" preference pages expose only the "instance"
level. That said, the IDE developer can specify (by means of a directive in the
prefspecs file itself) which of the levels should be exposed to the user, so
that the "standard" experience can be achieved if desired.
Preference Types
The types of preferences supported are:
- boolean
- ints
- doubles
- strings
- file paths
- directory paths
- directory lists
- fonts
- colors
- combo box (for enumerated types)
- radio button groups (an alternative presentation of enumerated types)