/*--------------------------------------------------------------------------*/
protected void addSearch(XMLElement spec)
{
Vector forPacks = spec.getChildrenNamed(SELECTEDPACKS);
Vector forOs = spec.getChildrenNamed(OS);
XMLElement element = spec.getFirstChildNamed(SPEC);
String variable = spec.getAttribute(VARIABLE);
String filename = null;
String check_filename = null;
int search_type = 0;
int result_type = 0;
JComboBox combobox = new JComboBox();
JLabel label = null;
// System.out.println ("adding search combobox, variable "+variable);
// allow the user to enter something
combobox.setEditable(true);
// ----------------------------------------------------
// extract the specification details
// ----------------------------------------------------
if (element != null)
{
label = new JLabel(getText(element));
// search type is optional (default: file)
search_type = SearchField.TYPE_FILE;
String search_type_str = element.getAttribute(SEARCH_TYPE);
if (search_type_str != null)
{
if (search_type_str.equals(SEARCH_FILE))
{
search_type = SearchField.TYPE_FILE;
}
else if (search_type_str.equals(SEARCH_DIRECTORY))
{
search_type = SearchField.TYPE_DIRECTORY;
}
}
// result type is mandatory too
String result_type_str = element.getAttribute(SEARCH_RESULT);
if (result_type_str == null)
{
return;
}
else if (result_type_str.equals(SEARCH_FILE))
{
result_type = SearchField.RESULT_FILE;
}
else if (result_type_str.equals(SEARCH_DIRECTORY))
{
result_type = SearchField.RESULT_DIRECTORY;
}
else if (result_type_str.equals(SEARCH_PARENTDIR))
{
result_type = SearchField.RESULT_PARENTDIR;
}
else
{
return;
}
// might be missing - null is okay
filename = element.getAttribute(SEARCH_FILENAME);
check_filename = element.getAttribute(SEARCH_CHECKFILENAME);
Vector choices = element.getChildrenNamed(SEARCH_CHOICE);
if (choices == null) { return; }
for (int i = 0; i < choices.size(); i++)
{
XMLElement choice_el = (XMLElement) choices.elementAt(i);
if (!OsConstraint.oneMatchesCurrentSystem(choice_el)) continue;
String value = choice_el.getAttribute(SEARCH_VALUE);
combobox.addItem(value);
String set = ((XMLElement) choices.elementAt(i)).getAttribute(SET);
if (set != null)