Creating a Custom Service Effectivity Configuration Panel
For a given attribute on a Service Effectivity object, you can customize the fields that are presented in the Add/Edit Service Effectivity dialogs and Service Effectivity filter for assigning its values.
This topic describes how to construct a configuration panel with the fields shown below. The panel is the area below the Type and Context fields.
Note the following requirements:
1. A Java class that extends ServiceEffectivityConfigType
Please refer to the following class as an example (ignore the line breaks):
codebase\com\ptc\arbortext\windchill\serviceEffectivityFilter\client\ui
\renderers\configTypes\SerialNumberDateConfigType.class
2. The class uses GXT layouts and components for the desired fields.
3. The attribute and the custom ServiceEffectivityConfigType class are registered in the ServiceEffectivityConfig.xml file.
Refer to Customizing Service Effectivity for information.
Summary of Methods
The following mandatory methods are inherited from ServiceEffectivtityConfigType and must be overwritten or implemented. Further detail for each is included in subsequent sections.
renderConfigType()
This method creates the panel and the fields it contains.
In the example, the following entries configure the fields:
The base panel is represented by a ContentPanel entry
The ContentPanel entry includes NoLegendFieldSet entries for the Serial Number and Date and Summary areas.
The FieldSet entry for the Serial Number and Date area contains one HorizontalPanel entry to hold the Serial Number fields and one for the Date fields.
The HorizontalPanel entry for the Serial Number fields contains Radio and TextField entries to represent the two types of information that can be entered.
The HorizontalPanel entry for the Date fields contains DateTimePicker entries.
The FieldSet entry for the text displayed in the Summary field is updated when any of the other field values are changed.
Optional listeners are added to the fields within this method to control valid input and the enabling/disabling of fields and buttons.
resetConfigType()
This method clears and resets all the fields. It is used with the following actions:
adding the criteria to the To Be Applied table on the Service Effectivity filter tab
clicking the Apply button when adding Service Effectivity
removing the context if it is mandatory
In the example, this method also disables all the fields to ensure the context is chosen before continuing. The context is mandatory for the Service Effectivity type.
getLocalizedLabel()
This method returns the localized resource string for the Service Effectivity Type.
To use the display name for the attribute that is registered in the Type and Attribute Management utility, return getDisplayName(). It has been set with this value in the super class.
populateConfigType(JSONObject jsonObject)
When filter criteria or a ServiceEffectivity object are created, the field values are converted to a JSONObject. This method takes the JSONObject, reads the field values, and repopulates the fields in the UI with these values.
It is used when the following actions occur:
a row is selected in the To Be Applied table in the filter
the filter tab is reopened when a filter is applied
a saved filter is applied and the tab opened
an existing ServiceEffectivity object is edited
The JSONObject can have any attributes and values but does require a custom filter delegate that can read and handle them.
isContextMandatory()
This specifies whether the context field is mandatory for the selected Service Effectivity type. It can be used to control whether fields are disabled if this is not set and whether they are cleared when the context is removed.
addDetailSummary()
This is only used if the Summary field set has been created. It updates the text within the field. If the Summary field is not required, this method does not need to be implemented.
initializeConfigType(JSONObject innerObject)
Given the JSONObject representing the Service Effectivity fields, this method is used within the filter tab to initialize the models in the To Be Applied table when populating the tab.
addConfigType()
In the Service Effectivity filter tab, this method creates the model and adds it to the To Be Applied table.
detail represents the string that is displayed in the Value column of the table.
For example:
JSONObject latestJSON = getJsonFromFields();
String detail = valueText.getRawValue();
SETabInfoModel cm = new SETabInfoModel(getLocalizedLabel(),
ServiceEffectivityHelper.
getEffContextAsStringFromWidget(getEffContext(), true), detail, latestJSON,
getConfigTypeId());
return cm;
getJsonFromFields()
This method creates a JSONObject from the values set in the fields. This object is different for every Service Effectivity Type and is handled by the filter delegate.
getAllowAddingConfigType()
This method returns the allowAddingConfigType boolean property, which is used to enable/disable buttons on the forms if the fields do not pass validation.
Isto foi útil?