From: amwaterhouse Date: Wed, 23 Mar 2005 11:55:39 +0000 (+0000) Subject: override showSaveDialog to prompt user if file exists X-Git-Tag: Release_2_0~523 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c1c3302d36200898b0af17000b84fd26a63e2c37;p=jalview.git override showSaveDialog to prompt user if file exists --- diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 4dba60d..5b4fa21 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -45,6 +45,23 @@ public class JalviewFileChooser extends JFileChooser initColumns(); } + public int showSaveDialog(Component parent) throws HeadlessException { + setDialogType(SAVE_DIALOG); + int ret = showDialog(parent, null); + + if(ret == JalviewFileChooser.APPROVE_OPTION && getSelectedFile().exists() ) + { + int confirm = JOptionPane.showConfirmDialog(parent, + "Overwrite existing file?", + "File exists", + JOptionPane.YES_NO_OPTION); + if(confirm!=JOptionPane.YES_OPTION) + ret = this.CANCEL_OPTION; + } + return ret; + } + + void initColumns() { if (COLUMNS == null) @@ -58,7 +75,6 @@ public class JalviewFileChooser extends JFileChooser UIManager.getString("FileChooser.fileAttrHeaderText",l) }; } - } /**************************************************************************