Preference Sets are defined in XML descriptor files referred to as templates. The templates are written using a format that allows preferences to be generically described. The template must include all information required to render and validate each preference included.
Each preference is defined with sufficient information that the Editor can construct GUI pages that look and act almost as if written specifically for those data items. In the XML template, the plug-in developer can:
- Set a name for the Preference Set/Policy Type.
- Provide translated display names for the Policy Type
- Provide translated descriptions for the Policy Type
- Create individual preferences within a Policy Type
- Provide translated display names for the preference
- Set the scope
- Set the qualifier
- Set the key
- Optionally, set a default for the preference’s value.
- Set the item's type, such as "URL", “Integer" or “boolean”. This is used by the GUI to draw to an appropriate input entry and validate input to meet the requirements of that type.
- Provide a limited set of possible values to select from. These are usually presented in a drop down list.
- Set whether a value is required to be entered or can be left blank
The Editor looks at each preference, and provides appropriate validation and error messages when the administrator enters invalid data. The GUI also uses the type to determine what format of input field to generate. A boolean will get a check box, a string will get an edit field. Once input is provided, it is validated to ensure the data provided matches the designated type. The complete list of types supported is:
- string -- a java.lang.String, no restrictions on values
- boolean – defaults to “true” and “false”
- integer -- convertible to a java.lang.Integer
- real -- convertible to a java.lang.Double
- url -- convertible to a valid java.net.URL
Preferences can have additional constraints defined. Constraints set additional limits on the values that can be entered. The current list of supported constraints is:
- Enumeration -- a restricted list of values to choose from. The GUI will generate a drop down list box containing only these values.
- Minimum value <min> -- for integer and real types, the value must be equal to or greater than the minimum
- Minimum length <min> -- for non-numeric types, the minimum number of characters that must be entered
- Maximum value <max> -- for numeric types, the value must be equal to or less than the maximum
- Maximum length <max> -- for all other types, the maximum number of characters that may be entered
- BooleanValues -- the value must conform to one of two values determined by the user. The default is true/false, but any two string values can be set using <trueValue> and <falseValue>
Each Preference Set contains enough information to allow the Editor to dynamically generate appropriate data entry entities, with translated labels. Many errors in data entry can be caught on the server by validating the data against the definitions in the Preference. Translated error messages are displayed, prompting the administrator on how to correct their entries.
Parent topic: Creating Eclipse Preference Sets with the Policy Type Editor: XPD621