use of dr.app.beauti.util.BEAUTiImporter in project beast-mcmc by beast-dev.
the class BeautiFrame method doImportTraits.
public final boolean doImportTraits() {
if (options.taxonList != null) {
// validation of check empty taxonList
File[] files = selectImportFiles("Import Traits File...", false, new FileNameExtensionFilter[] { new FileNameExtensionFilter("Tab-delimited text files", "txt", "tab", "dat") });
if (files != null && files.length != 0) {
try {
BEAUTiImporter beautiImporter = new BEAUTiImporter(this, options);
beautiImporter.importTraits(files[0]);
} catch (FileNotFoundException fnfe) {
JOptionPane.showMessageDialog(this, "Unable to open file: File not found", "Unable to open file", JOptionPane.ERROR_MESSAGE);
return false;
} catch (IOException ioe) {
JOptionPane.showMessageDialog(this, "Unable to read file: " + ioe.getMessage(), "Unable to read file", JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception ex) {
ex.printStackTrace(System.err);
JOptionPane.showMessageDialog(this, "Fatal exception: " + ex, "Error reading file", JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
return false;
}
} else {
return false;
}
traitsPanel.fireTraitsChanged();
setAllOptions();
tabbedPane.setSelectedComponent(traitsPanel);
return true;
} else {
JOptionPane.showMessageDialog(this, "No taxa loaded yet, please import Alignment file.", "No taxa loaded", JOptionPane.ERROR_MESSAGE);
return false;
}
}
use of dr.app.beauti.util.BEAUTiImporter in project beast-mcmc by beast-dev.
the class BeautiFrame method importFiles.
private void importFiles(File[] files) {
for (File file : files) {
if (file == null || file.getName().equals("")) {
JOptionPane.showMessageDialog(this, "Invalid file name", "Invalid file name", JOptionPane.ERROR_MESSAGE);
} else {
try {
BEAUTiImporter beautiImporter = new BEAUTiImporter(this, options);
beautiImporter.importFromFile(file);
setDirty();
// } catch (FileNotFoundException fnfe) {
// JOptionPane.showMessageDialog(this, "Unable to open file: File not found",
// "Unable to open file", JOptionPane.ERROR_MESSAGE);
} catch (IOException ioe) {
JOptionPane.showMessageDialog(this, "File I/O Error unable to read file: " + ioe.getMessage(), "Unable to read file", JOptionPane.ERROR_MESSAGE);
ioe.printStackTrace();
// there may be other files in the list so don't return
// return;
} catch (MissingBlockException ex) {
JOptionPane.showMessageDialog(this, "TAXON, DATA or CHARACTERS block is missing in Nexus file: " + ex, "Missing Block in Nexus File", JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
} catch (ImportException ime) {
JOptionPane.showMessageDialog(this, "Error parsing imported file: " + ime, "Error reading file", JOptionPane.ERROR_MESSAGE);
ime.printStackTrace();
} catch (JDOMException jde) {
JOptionPane.showMessageDialog(this, "Error parsing imported file: " + jde, "Error reading file", JOptionPane.ERROR_MESSAGE);
jde.printStackTrace();
}
}
}
if (!options.hasIdenticalTaxa()) {
// need this to refresh panels otherwise it will throw exception
setAllOptions();
dataPanel.selectAll();
dataPanel.unlinkTreeModels();
}
setAllOptions();
}
use of dr.app.beauti.util.BEAUTiImporter in project beast-mcmc by beast-dev.
the class GLMSettingsPanel method importPredictors.
private boolean importPredictors() {
File[] files = frame.selectImportFiles("Import Predictors File...", false, new FileNameExtensionFilter[] { new FileNameExtensionFilter("Tab-delimited text files", "txt", "tab", "dat") });
if (files != null && files.length != 0) {
try {
BEAUTiImporter beautiImporter = new BEAUTiImporter(frame, options);
beautiImporter.importPredictors(files[0], trait);
} catch (FileNotFoundException fnfe) {
JOptionPane.showMessageDialog(this, "Unable to open file: File not found", "Unable to open file", JOptionPane.ERROR_MESSAGE);
return false;
} catch (IOException ioe) {
JOptionPane.showMessageDialog(this, "Unable to read file: " + ioe.getMessage(), "Unable to read file", JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception ex) {
ex.printStackTrace(System.err);
JOptionPane.showMessageDialog(this, "Fatal exception: " + ex, "Error reading file", JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
return false;
}
} else {
return false;
}
firePredictorsChanged();
return true;
}
Aggregations