/*--------------------------------------------------------------------------*/
protected void addRuleField(XMLElement spec)
{
Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
Vector forOs = spec.getChildrenNamed(OS);
XMLElement element = spec.getFirstChildNamed(SPEC);
String variable = spec.getAttribute(VARIABLE);
RuleInputField field = null;
JLabel label;
String layout;
String set;
String separator;
String format;
String validator = null;
String message = null;
boolean hasParams = false;
String paramName = null;
String paramValue = null;
HashMap validateParamMap = null;
Vector validateParams = null;
String processor = null;
int resultFormat = RuleInputField.DISPLAY_FORMAT;
// ----------------------------------------------------
// extract the specification details
// ----------------------------------------------------
if (element != null)
{
label = new JLabel(getText(element));
layout = element.getAttribute(RULE_LAYOUT);
set = element.getAttribute(SET);
// retrieve value of variable if not specified
// (does not work here because of special format for set attribute)
// if (set == null)
// {
// set = idata.getVariable (variable);
// }
separator = element.getAttribute(RULE_SEPARATOR);
format = element.getAttribute(RULE_RESULT_FORMAT);
if (format != null)
{
if (format.equals(RULE_PLAIN_STRING))
{
resultFormat = RuleInputField.PLAIN_STRING;
}
else if (format.equals(RULE_DISPLAY_FORMAT))
{
resultFormat = RuleInputField.DISPLAY_FORMAT;
}
else if (format.equals(RULE_SPECIAL_SEPARATOR))
{
resultFormat = RuleInputField.SPECIAL_SEPARATOR;
}
else if (format.equals(RULE_ENCRYPTED))
{
resultFormat = RuleInputField.ENCRYPTED;
}
}
}
// ----------------------------------------------------
// if there is no specification element, return without
// doing anything.
// ----------------------------------------------------
else
{
return;
}
// ----------------------------------------------------
// get the description and add it to the list of UI
// elements if it exists.
// ----------------------------------------------------
element = spec.getFirstChildNamed(DESCRIPTION);
addDescription(element, forPacks, forOs, null);
// ----------------------------------------------------
// get the validator and processor if they are defined
// ----------------------------------------------------
element = spec.getFirstChildNamed(VALIDATOR);
if (element != null)
{
validator = element.getAttribute(CLASS);
message = getText(element);
// ----------------------------------------------------------
// check and see if we have any parameters for this validator.
// If so, then add them to validateParamMap.
// ----------------------------------------------------------
validateParams = element.getChildrenNamed(RULE_PARAM);
if (validateParams != null && validateParams.size() > 0 && validateParamMap == null)
{
validateParamMap = new HashMap();
hasParams = true;
}
for (Iterator it = validateParams.iterator(); it.hasNext();)
{
element = (XMLElement) it.next();
paramName = element.getAttribute(RULE_PARAM_NAME);
paramValue = element.getAttribute(RULE_PARAM_VALUE);
validateParamMap.put(paramName, paramValue);
}
}
element = spec.getFirstChildNamed(PROCESSOR);
if (element != null)
{
processor = element.getAttribute(CLASS);
}
// ----------------------------------------------------
// create an instance of RuleInputField based on the
// extracted specifications, then add it to the list