+ Component saveparent;
+ RunResponse overwriteCheck = new RunResponse(
+ JalviewFileChooser.APPROVE_OPTION)
+ {
+ @Override
+ public void run()
+ {
+ // JBP Note - this code was executed regardless of 'SAVE' being pressed
+ // need to see if there were side effects
+ if (getFileFilter() instanceof JalviewFileFilter)
+ {
+ JalviewFileFilter jvf = (JalviewFileFilter) getFileFilter();
+
+ if (!jvf.accept(getSelectedFile()))
+ {
+ String withExtension = getSelectedFile() + "."
+ + jvf.getAcceptableExtension();
+ setSelectedFile(new File(withExtension));
+ }
+ }
+ // All good, so we continue to save
+ returned = new Response(JalviewFileChooser.APPROVE_OPTION);
+
+ // TODO: ENSURE THAT FILES SAVED WITH A ':' IN THE NAME ARE REFUSED AND THE
+ // USER PROMPTED FOR A NEW FILENAME
+ /**
+ * @j2sNative
+ */
+ {
+ if (getSelectedFile().exists())
+ {
+ // JAL-3048 - may not need to raise this for browser saves
+
+ // yes/no cancel
+ int confirm = JvOptionPane.showConfirmDialog(saveparent,
+ MessageManager.getString("label.overwrite_existing_file"),
+ MessageManager.getString("label.file_already_exists"),
+ JvOptionPane.YES_NO_OPTION);
+
+ if (confirm != JvOptionPane.YES_OPTION)
+ {
+ returned = new Response(JalviewFileChooser.CANCEL_OPTION);
+ }
+ }
+ }
+ };
+ };
+