Search in sources :

Example 1 with DataParserOptionsDialog

use of uk.ac.babraham.SeqMonk.Dialogs.DataParser.DataParserOptionsDialog in project SeqMonk by s-andrews.

the class SeqMonkApplication method importData.

/**
 * Begins the import of new SequenceRead data
 *
 * @param parser A DataParser which will actually do the importing.
 */
public void importData(DataParser parser) {
    parser.addProgressListener(this);
    JFileChooser chooser = new JFileChooser(SeqMonkPreferences.getInstance().getDataLocation());
    chooser.setMultiSelectionEnabled(true);
    FileFilter filter = parser.getFileFilter();
    if (filter != null) {
        chooser.setFileFilter(parser.getFileFilter());
        int result = chooser.showOpenDialog(this);
        /*
			 * There seems to be a bug in the file chooser which allows the user to
			 * select no files, but not cancel if the control+double click on a file
			 */
        if (result == JFileChooser.CANCEL_OPTION || chooser.getSelectedFile() == null) {
            return;
        }
        SeqMonkPreferences.getInstance().setLastUsedDataLocation(chooser.getSelectedFile());
        parser.setFiles(chooser.getSelectedFiles());
    }
    // See if we need to display any options
    if (parser.hasOptionsPanel()) {
        DataParserOptionsDialog optionsDialog = new DataParserOptionsDialog(parser);
        optionsDialog.setLocationRelativeTo(this);
        boolean goAhead = optionsDialog.view();
        if (!goAhead) {
            return;
        }
    }
    ProgressDialog pd = new ProgressDialog(this, "Loading data...", parser);
    parser.addProgressListener(pd);
    try {
        parser.parseData();
    } catch (SeqMonkException ex) {
        throw new IllegalStateException(ex);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FileFilter(javax.swing.filechooser.FileFilter) ProgressDialog(uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog) DataParserOptionsDialog(uk.ac.babraham.SeqMonk.Dialogs.DataParser.DataParserOptionsDialog)

Aggregations

JFileChooser (javax.swing.JFileChooser)1 FileFilter (javax.swing.filechooser.FileFilter)1 DataParserOptionsDialog (uk.ac.babraham.SeqMonk.Dialogs.DataParser.DataParserOptionsDialog)1 ProgressDialog (uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog)1