import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
-import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
/**
if (fileName == null || (currentFileFormat == null)
|| fileName.startsWith("http"))
{
- saveAs_actionPerformed(null);
+ saveAs_actionPerformed();
}
else
{
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Saves the alignment to a file with a name chosen by the user, if necessary
+ * warning if a file would be overwritten
*/
@Override
- public void saveAs_actionPerformed(ActionEvent e)
+ public void saveAs_actionPerformed()
{
String format = currentFileFormat == null ? null
: currentFileFormat.getName();
- final JalviewFileChooser chooser = JalviewFileChooser
+ JalviewFileChooser chooser = JalviewFileChooser
.forWrite(Cache.getProperty("LAST_DIRECTORY"), format);
- final AlignFrame us = this;
+
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(
MessageManager.getString("label.save_alignment_to_file"));
chooser.setToolTipText(MessageManager.getString("action.save"));
- chooser.response(new RunResponse(JalviewFileChooser.APPROVE_OPTION)
+ int value = chooser.showSaveDialog(this);
+
+ if (value == JalviewFileChooser.APPROVE_OPTION)
{
- @Override
- public void run()
+ currentFileFormat = chooser.getSelectedFormat();
+ while (currentFileFormat == null)
{
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString(
+ "label.select_file_format_before_saving"),
+ MessageManager.getString("label.file_format_not_specified"),
+ JvOptionPane.WARNING_MESSAGE);
currentFileFormat = chooser.getSelectedFormat();
- while (currentFileFormat == null)
+ value = chooser.showSaveDialog(this);
+ if (value != JalviewFileChooser.APPROVE_OPTION)
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.getString(
- "label.select_file_format_before_saving"),
- MessageManager
- .getString("label.file_format_not_specified"),
- JvOptionPane.WARNING_MESSAGE);
- currentFileFormat = chooser.getSelectedFormat();
- chooser.showSaveDialog(us);
+ return;
}
+ }
- fileName = chooser.getSelectedFile().getPath();
-
- Cache.setProperty("DEFAULT_FILE_FORMAT",
- currentFileFormat.getName());
+ fileName = chooser.getSelectedFile().getPath();
- Cache.setProperty("LAST_DIRECTORY", fileName);
- saveAlignment(fileName, currentFileFormat);
- }
- }).showSaveDialog(this);
+ Cache.setProperty("DEFAULT_FILE_FORMAT", currentFileFormat.getName());
+ Cache.setProperty("LAST_DIRECTORY", fileName);
+ saveAlignment(fileName, currentFileFormat);
+ }
}
private boolean lastSaveSuccessful = false;