// i.e. after de-serialization
setupFileChooser();
}
int returnVal = m_fileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File loadFrom = m_fileChooser.getSelectedFile();
// add extension if necessary
if (m_fileChooser.getFileFilter() == m_binaryFilter) {
if (!loadFrom.getName().toLowerCase().endsWith("." + FILE_EXTENSION)) {
loadFrom = new File(loadFrom.getParent(),
loadFrom.getName() + "." + FILE_EXTENSION);
}
} else if (m_fileChooser.getFileFilter() == m_KOMLFilter) {
if (!loadFrom.getName().toLowerCase().endsWith(KOML.FILE_EXTENSION
+ FILE_EXTENSION)) {
loadFrom = new File(loadFrom.getParent(),
loadFrom.getName() + KOML.FILE_EXTENSION
+ FILE_EXTENSION);
}
} else if (m_fileChooser.getFileFilter() == m_XStreamFilter) {
if (!loadFrom.getName().toLowerCase().endsWith(XStream.FILE_EXTENSION
+ FILE_EXTENSION)) {
loadFrom = new File(loadFrom.getParent(),
loadFrom.getName() + XStream.FILE_EXTENSION
+ FILE_EXTENSION);
}
}
weka.classifiers.Classifier temp = null;
Instances tempHeader = null;
// KOML ?
if ((KOML.isPresent()) &&
(loadFrom.getAbsolutePath().toLowerCase().
endsWith(KOML.FILE_EXTENSION + FILE_EXTENSION))) {
Vector v = (Vector) KOML.read(loadFrom.getAbsolutePath());
temp = (weka.classifiers.Classifier) v.elementAt(0);
if (v.size() == 2) {
// try and grab the header
tempHeader = (Instances) v.elementAt(1);
}
} /* XStream */ else if ((XStream.isPresent()) &&
(loadFrom.getAbsolutePath().toLowerCase().
endsWith(XStream.FILE_EXTENSION + FILE_EXTENSION))) {
Vector v = (Vector) XStream.read(loadFrom.getAbsolutePath());
temp = (weka.classifiers.Classifier) v.elementAt(0);
if (v.size() == 2) {
// try and grab the header
tempHeader = (Instances) v.elementAt(1);
}