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: objectToString method
2) How to edit/process the value in the Edit Preference wizard: getEditGuiComponent and process methods
3) How to validate the inputted values: validate methods
4) How to display the value in the Preference Manager tree table: getViewGuiComponent method

When 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 ChoicePreferenceValueHandler


Supported API: true

Extendable: true
  • Method Details

    • initialize

      void initialize(String aString)
      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

      String objectToString(Object anObject)
      This method converts the inputted preference type Object to a String to save the preference value in the database.

      Supported API: true
      Parameters:
      anObject -
      Returns:
      String
    • stringToObject

      Object stringToObject(String aString)
      This method converts the inputted String value stored in the database to the preference value Object.

      Supported API: true
      Parameters:
      aString -
      Returns:
      Object
    • validate

      Object[] validate(String aString)
      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

      Object[] validate(Object anObject)
      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

      Object getViewGuiComponent(Object anObject)
      This method specifies how the preference value is displayed in the Preference Manager tree table. Even though the signature accepts Object as an argument, this method expects either a PreferenceDefiniton or PreferenceInstance object 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 - PreferenceDefintion
      client - PreferenceClient the value will be set for the given PreferenceDefinition
      instances -
      contextObject - context the value will be set for the given PreferenceDefinition
      Returns:
      Object
    • process

      Object process(Object objectBean)
      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 the SetPreferenceValueFormProcessor from the Edit Preference wizard. The value returned by this method will be set by one of the setValue() API's on the PreferenceService2 class.

      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. See AccessPermissionPreferenceValueHandler for an example.

      Supported API: true
      Returns:
      boolean
    • multiPreferences

      Collection<PreferenceDefinition> multiPreferences()
      Returns a Collection of PreferenceDefinition objects 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

      Object getViewGuiComponent(Object anObject, PreferenceClient client, WTObject contextObject)
      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 PreferenceInstance
      client - - PreferenceClient
      contextObject - - Context object.
      Returns:
    • getValue

      Object getValue(PreferenceInstance instance)
      Gets the value from a preference instance

      Supported API: true
      Parameters:
      instance - - instance from which the value is to be obtained
      Returns:
    • getValue

      Object getValue(PreferenceDefinition definition)
      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 obtained
      organization -
      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 obtained
      organization -
      container -
      user -
      Returns:
    • setValue

      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: true
      WTException
    • isValueChanged

      boolean isValueChanged(PreferenceInstance instance, Object value) throws WTException
      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