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);
}
}
Aggregations