use of uk.ac.babraham.SeqMonk.Utilities.FileFilters.TxtFileFilter in project SeqMonk by s-andrews.
the class ReportTableDialog method actionPerformed.
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent ae) {
if (ae.getActionCommand().equals("close")) {
setVisible(false);
dispose();
} else if (ae.getActionCommand().equals("save")) {
JFileChooser chooser = new JFileChooser(SeqMonkPreferences.getInstance().getSaveLocation());
chooser.setMultiSelectionEnabled(false);
if (report.canExportGFF()) {
chooser.addChoosableFileFilter(new GFFFileFilter());
}
TxtFileFilter txtff = new TxtFileFilter();
chooser.addChoosableFileFilter(txtff);
chooser.setFileFilter(txtff);
int result = chooser.showSaveDialog(this);
if (result == JFileChooser.CANCEL_OPTION)
return;
File file = chooser.getSelectedFile();
SeqMonkPreferences.getInstance().setLastUsedSaveLocation(file);
if (file.isDirectory())
return;
FileFilter filter = chooser.getFileFilter();
if (filter instanceof TxtFileFilter) {
if (!file.getPath().toLowerCase().endsWith(".txt")) {
file = new File(file.getPath() + ".txt");
}
} else if (filter instanceof GFFFileFilter) {
if (!file.getPath().toLowerCase().endsWith(".gff")) {
file = new File(file.getPath() + ".gff");
}
} else {
System.err.println("Unknown file filter type " + filter + " when saving image");
return;
}
// Check if we're stepping on anyone's toes...
if (file.exists()) {
int answer = JOptionPane.showOptionDialog(this, file.getName() + " exists. Do you want to overwrite the existing file?", "Overwrite file?", 0, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Overwrite and Save", "Cancel" }, "Overwrite and Save");
if (answer > 0) {
return;
}
}
try {
if (filter instanceof TxtFileFilter) {
saveTextReport(file);
} else if (filter instanceof GFFFileFilter) {
saveGFFReport(file);
} else {
System.err.println("Unknown file filter type " + filter + " when saving image");
return;
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
use of uk.ac.babraham.SeqMonk.Utilities.FileFilters.TxtFileFilter in project SeqMonk by s-andrews.
the class ProbeValueHistogramPlot method actionPerformed.
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent ae) {
if (ae.getActionCommand().equals("close")) {
setVisible(false);
dispose();
} else if (ae.getActionCommand().equals("save")) {
ImageSaver.saveImage(plotPanel.mainHistogramPanel());
} else if (ae.getActionCommand().equals("export")) {
JFileChooser chooser = new JFileChooser(SeqMonkPreferences.getInstance().getSaveLocation());
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(new TxtFileFilter());
int result = chooser.showSaveDialog(this);
if (result == JFileChooser.CANCEL_OPTION)
return;
File file = chooser.getSelectedFile();
SeqMonkPreferences.getInstance().setLastUsedSaveLocation(file);
if (file.isDirectory())
return;
if (!file.getPath().toLowerCase().endsWith(".txt")) {
file = new File(file.getPath() + ".txt");
}
// Check if we're stepping on anyone's toes...
if (file.exists()) {
int answer = JOptionPane.showOptionDialog(this, file.getName() + " exists. Do you want to overwrite the existing file?", "Overwrite file?", 0, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Overwrite and Save", "Cancel" }, "Overwrite and Save");
if (answer > 0) {
return;
}
}
try {
plotPanel.exportData(file);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
Aggregations