Package wt.preference
Interface PreferenceValueHandler
- All Known Subinterfaces:
MultiValuedPreferenceHandler
- All Known Implementing Classes:
com.ptc.windchill.enterprise.preference.handler.AbstractPreferenceValueHandler,ContentCachePreferenceValueHandler
public interface PreferenceValueHandler
Interface specifying behavior needed for processing the preference values.
Each PreferenceDefinition has one and it contains all the logic specifying:
1) How to store the value:
2) How to edit/process the value in the Edit Preference wizard:
3) How to validate the inputted values:
4) How to display the value in the Preference Manager tree table:
When creating a new preference handler, extend the abstract class
-- String value handler: See
-- Boolean value handler: See
-- Number value handler: See
-- Multi-choice value handler: See
Supported API: true
Extendable: true
1) How to store the value:
objectToString method2) How to edit/process the value in the Edit Preference wizard:
getEditGuiComponent
and process methods3) How to validate the inputted values:
validate methods4) How to display the value in the Preference Manager tree table:
getViewGuiComponent
methodWhen creating a new preference handler, extend the abstract class
AbstractPreferenceValueHandler.
Some basic preference value handlers have been defined:-- String value handler: See
StringPreferenceValueHandler-- Boolean value handler: See
BooleanPreferenceValueHandler-- Number value handler: See
NumberPreferenceValueHandler-- Multi-choice value handler: See
ChoicePreferenceValueHandlerSupported API: true
Extendable: true
-
Method Summary
Modifier and TypeMethodDescriptiongetEditGuiComponent(PreferenceDefinition definition, PreferenceClient client, Collection<PreferenceInstance> instances, WTObject contextObject) This method is called from the Edit Preference wizard on the Preference Manager tree table.getValue(PreferenceDefinition definition) Gets the default value from a preference definition
Supported API: truegetValue(PreferenceDefinition definition, OrgContainer organization, WTContainer container, WTUser user) Gets the value from a preference definition
Supported API: truegetValue(PreferenceInstance instance) Gets the value from a preference instance
Supported API: truegetValue(PreferenceInstance instance, OrgContainer organization, WTContainer container, WTUser user) Gets the value from a preference instance
Supported API: truegetViewGuiComponent(Object anObject) This method specifies how the preference value is displayed in the Preference Manager tree table.getViewGuiComponent(Object anObject, PreferenceClient client, WTObject contextObject) Specifies how the preference is viewed in the GUI.voidinitialize(String aString) Allows for handler specific data to be processed upon initialization.booleanDetermines if the preference value handler manages more than one key value pair for one preference.booleanDetermines if the preference value handler manages more than one preference.booleanisValueChanged(PreferenceInstance instance, Object value) Determines if the preference instance value is same as value specified by object.Returns a Collection ofPreferenceDefinitionobjects if this handler manages multiple preferences.Returns the Class type of the Preference value handler.objectToString(Object anObject) This method converts the inputted preference type Object to aStringto save the preference value in the database.Processes ObjectBean to get preference value to be set.setValue(PreferenceInstance instance, Object value) Sets the value for the preference instance to the value specified by the object after converting it to stringstringToObject(String aString) This method converts the inputted String value stored in the database to the preference value Object.stringToObject(String aString, OrgContainer organization, WTContainer container, WTUser user) This method converts the inputted String value stored in the database to the preference value Object.Object[]Validates an inputted value object.Object[]Validates an inputted string value.
-
Method Details
-
initialize
Allows for handler specific data to be processed upon initialization. The String value passed to this method needs to appended to the class name defined in the preference load XML files. Example:
<csvhandler>...handler.StringPreferenceValueHandler:initialization_string</csvhandler> where initialization_string will be passed as an argument to this method.
Supported API: true- Parameters:
aString-
-
objectToString
This method converts the inputted preference type Object to aStringto save the preference value in the database.
Supported API: true- Parameters:
anObject-- Returns:
- String
-
stringToObject
This method converts the inputted String value stored in the database to the preference value Object.
Supported API: true- Parameters:
aString-- Returns:
- Object
-
validate
Validates an inputted string value. Returns an Object[] with 2 elements. The first element is of type Boolean, indicating whether the input is valid or not. The second element may be null or a WTMessage containing an explanation of the validation result.
Supported API: true- Parameters:
aString-- Returns:
- Object[]
-
validate
Validates an inputted value object. Returns an Object[] with 2 elements. The first element is of type Boolean, indicating whether the input is valid or not. The second element may be null or a WTMessage containing an explanation of the validation result.
Supported API: true- Parameters:
anObject-- Returns:
- Object[]
-
getViewGuiComponent
This method specifies how the preference value is displayed in the Preference Manager tree table. Even though the signature acceptsObjectas an argument, this method expects either aPreferenceDefinitonorPreferenceInstanceobject to be passed in. If a PreferenceDefinition is passed in, then the preference's default value is returned otherwise the value associated to the PreferenceInstance is returned.
Supported API: true- Parameters:
anObject- should be either a PreferenceDefinition or PreferenceInstance object.- Returns:
- Object
-
getEditGuiComponent
Object getEditGuiComponent(PreferenceDefinition definition, PreferenceClient client, Collection<PreferenceInstance> instances, WTObject contextObject) This method is called from the Edit Preference wizard on the Preference Manager tree table. A GUIComponent is returned to allow for editing of the preference value.
Supported API: true- Parameters:
definition- PreferenceDefintionclient- PreferenceClient the value will be set for the given PreferenceDefinitioninstances-contextObject- context the value will be set for the given PreferenceDefinition- Returns:
- Object
-
process
Processes ObjectBean to get preference value to be set. Though the signature allows Objects, this method expects an ObjectBean containing the http request data with the preference value to be set. This method is called by theSetPreferenceValueFormProcessorfrom the Edit Preference wizard. The value returned by this method will be set by one of the setValue() API's on thePreferenceService2class.
Supported API: true- Parameters:
objectBean-- Returns:
- Object
-
objectClass
Class objectClass()Returns the Class type of the Preference value handler.
Supported API: true- Returns:
- Class
-
isMultiPreference
boolean isMultiPreference()Determines if the preference value handler manages more than one preference. SeeAccessPermissionPreferenceValueHandlerfor an example.
Supported API: true- Returns:
- boolean
-
multiPreferences
Collection<PreferenceDefinition> multiPreferences()Returns a Collection ofPreferenceDefinitionobjects if this handler manages multiple preferences.
Supported API: true- Returns:
- Collection
-
stringToObject
Object stringToObject(String aString, OrgContainer organization, WTContainer container, WTUser user) This method converts the inputted String value stored in the database to the preference value Object.
Supported API: true -
getViewGuiComponent
Specifies how the preference is viewed in the GUI. Includes a PreferenceClient and context arguments to allow for more processing of a preference value if needed.
Supported API: true- Parameters:
anObject- - Object is either a PreferenceDefinition or PreferenceInstanceclient- - PreferenceClientcontextObject- - Context object.- Returns:
-
getValue
Gets the value from a preference instance
Supported API: true- Parameters:
instance- - instance from which the value is to be obtained- Returns:
-
getValue
Gets the default value from a preference definition
Supported API: true- Parameters:
definition- - definition from which the default value is to be obtained- Returns:
-
getValue
Object getValue(PreferenceInstance instance, OrgContainer organization, WTContainer container, WTUser user) Gets the value from a preference instance
Supported API: true- Parameters:
instance- - instance from which the value is to be obtainedorganization-container-user-- Returns:
-
getValue
Object getValue(PreferenceDefinition definition, OrgContainer organization, WTContainer container, WTUser user) Gets the value from a preference definition
Supported API: true- Parameters:
definition- - definition from which the default value is to be obtainedorganization-container-user-- Returns:
-
setValue
PreferenceInstance setValue(PreferenceInstance instance, Object value) throws WTPropertyVetoException, WTException Sets the value for the preference instance to the value specified by the object after converting it to string- Parameters:
instance-value-- Throws:
WTPropertyVetoException-
Supported API: trueWTException
-
isValueChanged
Determines if the preference instance value is same as value specified by object. If the instance value is bull it shoulod return true as an indication of new PreferenceInstance to be saved
Supported API: true- Parameters:
instance-value-- Returns:
- Throws:
WTException
-
isMultiMapPreference
boolean isMultiMapPreference()Determines if the preference value handler manages more than one key value pair for one preference.
Supported API: true- Returns:
- boolean
-