//This method will invoke the classifier's setOptions
//method to see if the current set of options was
//valid.
EnsembleLibraryModel model = m_ListModelsPanel.getLibrary().createModel(classifier);
model.testOptions();
if (!model.getOptionsWereValid())
invalid++;
dataModel.add(model);
}
//update the message text with model generation info
String generateString = new String(" " + total
+ " models generated");
generateString += ", " + invalid + " had errors";
m_GenerateLabel.setText(generateString);
} else if (e.getSource() == m_RemoveSelectedButton) {
//here we simply get the list of models that are
//currently selected and ten remove them from the list
Object[] currentModels = m_ModelList.getSelectedValues();
for (int i = 0; i < currentModels.length; i++) {
dataModel.removeElement(currentModels[i]);
}
//Shrink the selected range to the first index that was selected
if (m_ModelList.getSelectedIndices().length > 0) {
int selected[] = new int[1];
selected[0] = m_ModelList.getSelectedIndices()[0];
m_ModelList.setSelectedIndices(selected);
}
} else if (e.getSource() == m_RemoveInvalidButton) {
//here we simply remove all the models that were not
//valid
Vector toRemove = new Vector();
for (int i = 0; i < dataModel.getSize(); i++) {
EnsembleLibraryModel currentModel = (EnsembleLibraryModel) dataModel.getElementAt(i);
if (!currentModel.getOptionsWereValid()) {
toRemove.add(currentModel);
}
}
for (int i = 0; i < toRemove.size(); i++)
dataModel.removeElement(toRemove.get(i));
} else if (e.getSource() == m_AddAllButton) {
//here we just need to add all of the models to the
//ListModelsPanel object
Iterator it = dataModel.iterator();
while (it.hasNext()) {
EnsembleLibraryModel currentModel = (EnsembleLibraryModel) it.next();
if (currentModel.getOptionsWereValid()) {
m_ListModelsPanel.addModel(currentModel);
}
}
int size = dataModel.getSize();