return null;
}
+ File ourselectedFile = null;
+
+ @Override
+ public File getSelectedFile()
+ {
+ File selfile = super.getSelectedFile();
+ if (selfile == null && ourselectedFile != null)
+ {
+ return ourselectedFile;
+ }
+ return selfile;
+ }
+
@Override
public int showSaveDialog(Component parent) throws HeadlessException
{
this.setSelectedFile(null);
int ret = showDialog(parent, MessageManager.getString("action.save"));
+ ourselectedFile = getSelectedFile();
if (getFileFilter() instanceof JalviewFileFilter)
{
JalviewFileFilter jvf = (JalviewFileFilter) getFileFilter();
- if (!jvf.accept(getSelectedFile()))
+ if (!jvf.accept(ourselectedFile))
{
- String withExtension = getSelectedFile() + "."
+ String withExtension = getSelectedFile().getName() + "."
+ jvf.getAcceptableExtension();
- setSelectedFile(new File(withExtension));
+ ourselectedFile = (new File(getCurrentDirectory(), withExtension));
+ setSelectedFile(ourselectedFile);
}
}
// TODO: ENSURE THAT FILES SAVED WITH A ':' IN THE NAME ARE REFUSED AND THE
// USER PROMPTED FOR A NEW FILENAME
if ((ret == JalviewFileChooser.APPROVE_OPTION)
- && getSelectedFile().exists())
+ && ourselectedFile.exists())
{
int confirm = JvOptionPane.showConfirmDialog(parent,
MessageManager.getString("label.overwrite_existing_file"),