X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FJalviewFileChooser.java;h=5b4fa212720bd74770f7c3a1dbd6e0c9104da33f;hb=24efbd38f2c3dceaf6d3e305eef41ba0b0c9ebdc;hp=4dba60dcf16d1c8dfa63326a0b7999d8adb22d68;hpb=6963fa5dd8cd395afc095fe1dabba37387034631;p=jalview.git 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) }; } - } /**************************************************************************