Search in sources :

Example 1 with BEAUTiImporter

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;
    }
}
Also used : FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) JDOMException(org.jdom.JDOMException) ImportException(dr.evolution.io.Importer.ImportException) MissingBlockException(dr.evolution.io.NexusImporter.MissingBlockException) BEAUTiImporter(dr.app.beauti.util.BEAUTiImporter)

Example 2 with BEAUTiImporter

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();
}
Also used : ImportException(dr.evolution.io.Importer.ImportException) JDOMException(org.jdom.JDOMException) BEAUTiImporter(dr.app.beauti.util.BEAUTiImporter) MissingBlockException(dr.evolution.io.NexusImporter.MissingBlockException)

Example 3 with BEAUTiImporter

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) BEAUTiImporter(dr.app.beauti.util.BEAUTiImporter)

Aggregations

BEAUTiImporter (dr.app.beauti.util.BEAUTiImporter)3 ImportException (dr.evolution.io.Importer.ImportException)2 MissingBlockException (dr.evolution.io.NexusImporter.MissingBlockException)2 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)2 JDOMException (org.jdom.JDOMException)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1