Personalización básica > User Interface Customization > Generic UI Customizations > Preference Framework > Preference Registry
  
Preference Registry
The preference registry is a way to take a cryptic name like a preference and provide a localized series of data about it. This registry is in the form of rbInfo files. Anyone adding preferences to the system will have the option of adding this localized information to the Preference Registry.
Adding a preference to the preference registry
To add a Preference to the Preference Registry, you need to edit the file <Windchill>src/wt/prefs/registry/prefRegistry.rbInfo and for the Preference you want to add, add at least:
DISPLAY_NAME
DESCRIPTION
DEFAULT
The format is as follows:
/node-name/key-name% [ ]tag.value=
Where /node-name is the name of the node (for example /wt/workflow), /key-name is the name of the key under the node (SortOrder) and % [ ]tag is one of the tags mentioned above (% [ ]DISPLAY_NAME).
Creating a Preference
The creation of a preference is done through an XML load file. When creating a preference the following pieces of information need to be determined:
Unique preference name
Visibility: if the preference will appear in the preference manager UI and visible at what contexts: SITE, ORGANIZATION, CONTAINER or USER.
Preference category: The category the new preference will appear under in the Preference Management utility.
Display name: This is the Name column in the Preference Management utility – string in the form <RBINFO>:< RBINFO key>
Description: This is the Description column in the Preference Management utility – string in the form:
<RBINFO>:<RBINFO key>
Long Description: This description is displayed in the Edit Preference UI, gives a more detailed description including the expected values.
string in the form <RBINFO>:<RBINFO key>
Default value
Value header
In the example below, we will create a new preference named /com/mycompany/MyNewPreference along with an associated preference category to appear in the Preference Manager UI.
1. Create a resource bundle for labels used for your new preference. Labels are needed for display name and description of preference category which the new preference will be visible under in Preference Management UI. Labels are also needed for the display name, description and long description of your preference. Create the file mycompanyPreferenceResource.rbInfo in package com.mycompany.pref. In this example, this file would be added to the <Windchill>/src/mycompany/pref directory.
ResourceInfo.class=wt.tools.resource.StringResourceInfo
ResourceInfo.customizable=true
ResourceInfo.deprecated=false

# Preference Category labels
MyNewPreferenceCategory.displayName.value=My Preference Category
MyNewPreferenceCategory.description.value=Preference Category for my
custom preferences.

# Preference Definition labels
MyNewPreference.displayName.value=Display name of preference /com/my
company/
MyNewPreference
MyNewPreference.description.value=Description of preference /com/myc
ompany/
MyNewPreference.
MyNewPreference.longDescription.value=Long description of preference
/com/mycompany/MyNewPreference.
2. Build the resource bundle by executing the following command from a windchill shell:
ResourceBuild com.mycompany.pref.mycompanyPreferenceResource
3. Restart the servlet engine and the MethodServer.
4. Create Preference load file: createMyNewPreference.xml. It will contain a definition for the new preference category and new preference definition.
<?xml version="1.0"?><!DOCTYPE NmLoader SYSTEM "standardX10.dtd">
<NmLoader>

<csvPreferenceCategory handler="wt.preference.LoadPreference.createPref
erenceCategory">
<csvname>CUSTOM_PREFERENCE_CATEGORY</csvname>
<csvparentName></csvparentName>
<csvdisplayName>
com.mycompany.pref.mycompanyPreferenceResource:
MyNewPreferenceCategory.displayName
</csvdisplayName>
<csvdescription>
com.mycompany.pref.mycompanyPreferenceResource:MyNewPreferenceCategory.
description
</csvdescription>
</csvPreferenceCategory>

<csvPreferenceDefinition handler="wt.preference.LoadPreference.createPref
erence
Definition">
<csvname>/com/mycompany/MyNewPreference</csvname>
<csvvisibility>USER</csvvisibility>

<csvcategoryName>CUSTOM_PREFERENCE_CATEGORY</csvcategoryName>

<csvdisplayName>com.mycompany.pref.mycompanyPreferenceResource:MyNew
Preference.displayName
</csvdisplayName>

<csvdescription>com.mycompany.pref.mycompanyPreferenceResource:MyNew
Preference
.description</csvdescription>

<csvlongDescription>com.mycompany.pref.mycompanyPreferenceResource:
MyNewPreference.longDescription</csvlongDescription>
<csvdefaultValue>Default Value</csvdefaultValue>

<csvhandler>com.ptc.windchill.enterprise.preference.handler.
StringPreferenceValue
Handler:4000
</csvhandler>
</csvPreferenceDefinition>

<csvLinkPreferenceClientDefinition handler="wt.preference.LoadPreference.set
ClientDefinitionLink">
<csvname>/com/mycompany/MyNewPreference</csvname>
<csvclientName>WINDCHILL</csvclientName>
</csvLinkPreferenceClientDefinition>

</NmLoader>
5. Load the preference category and preference definition using the following command:
windchill wt.load.LoadFromFile -d <full
path>/createMyNewPreference.xml
Deleting a Preference
The deletion of a preference is also done through the use of an XML load file. Using the example from the Creating a Preference section on page 9–20, we will delete the preference /com/mycompany/MyNewPreference. The deletion of the preference will also remove any preference instances which may have been set for this preference in the UI.
1. Create an XML file, deleteMyNewPreference.xml, containing the following definition to specify the deletion of the preference.
<?xml version="1.0"?><!DOCTYPE NmLoader SYSTEM
"standardX10.dtd">
<NmLoader>

<csvDeletePreferenceDefinition
handler="wt.preference.LoadPreference.deletePreferenceDefinition">
<csvname>/com/mycompany/MyNewPreference</csvname>
</csvDeletePreferenceDefinition>

</NmLoader>
2. Delete the preference definition using the following command:
windchill wt.load.LoadFromFile -d <full
path>/deleteMyNewPreference.xml
Preference Framework