From c1c3302d36200898b0af17000b84fd26a63e2c37 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 23 Mar 2005 11:55:39 +0000 Subject: [PATCH] override showSaveDialog to prompt user if file exists --- src/jalview/io/JalviewFileChooser.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) }; } - } /************************************************************************** -- 1.7.10.2