/*--------------------------------------------------------------------------*/
private void addComboBox(XMLElement spec)
{
Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
Vector forOs = spec.getChildrenNamed(OS);
XMLElement element = spec.getFirstChildNamed(SPEC);
String variable = spec.getAttribute(VARIABLE);
TextValuePair listItem = null;
JComboBox field = new JComboBox();
JLabel label;
Vector variables = new Vector();
Vector values = new Vector();
// ----------------------------------------------------
// extract the specification details
// ----------------------------------------------------
if (element != null)
{
label = new JLabel(getText(element));
Vector choices = element.getChildrenNamed(COMBO_CHOICE);
if (choices == null) { return; }
for (int i = 0; i < choices.size(); i++)
{
String processorClass = ((XMLElement) choices.elementAt(i))
.getAttribute("processor");
if (processorClass != null && !"".equals(processorClass))
{
String choiceValues = "";
try
{
choiceValues = ((Processor) Class.forName(processorClass).newInstance())
.process(null);
}
catch (Throwable t)
{
t.printStackTrace();
}
String set = ((XMLElement) choices.elementAt(i)).getAttribute(SET);
if (set == null)
{
set = "";
}
if (set != null && !"".equals(set)){
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
set = vs.substitute(set, null);
}
StringTokenizer tokenizer = new StringTokenizer(choiceValues, ":");
int counter = 0;
while (tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken();
listItem = new TextValuePair(token, token);
field.addItem(listItem);
if (set.equals(token))
{
field.setSelectedIndex(field.getItemCount() - 1);
}
counter++;
}
}
else
{
listItem = new TextValuePair(getText((XMLElement) choices.elementAt(i)),
((XMLElement) choices.elementAt(i)).getAttribute(COMBO_VALUE));
field.addItem(listItem);
XMLElement choiceElement = (XMLElement) choices.elementAt(i);
variables.add(spec.getAttribute(VARIABLE));
values.add("combo");
// handle additional variable-value assignments
Vector assignments = choiceElement.getChildrenNamed(ASSIGN);
for (int j = 0; j < assignments.size(); j++)
{
XMLElement assignmentElement = (XMLElement) assignments.get(j);
String variable2 = assignmentElement.getAttribute(VARIABLE);
if (variable2 != null)
{
variables.add(variable2);
values.add(assignmentElement.getAttribute(VALUE));
//values.add();
//System.out.println(variable2);
//idata.setVariable(variable2,assignmentElement.getAttribute(VALUE));
}