JAL-4001 GA4 tracking is now ENABLED. Currently logging a page_view like the website...
[jalview.git] / src / jalview / io / JalviewFileChooser.java
index 8cd5406..cb47610 100755 (executable)
@@ -45,6 +45,7 @@ import javax.swing.JCheckBox;
 import javax.swing.JDialog;
 import javax.swing.JFileChooser;
 import javax.swing.JList;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.SpringLayout;
@@ -53,7 +54,7 @@ import javax.swing.plaf.basic.BasicFileChooserUI;
 
 import jalview.bin.Cache;
 import jalview.gui.JvOptionPane;
-import jalview.gui.WindowIcons;
+import jalview.util.ChannelProperties;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.util.dialogrunner.DialogRunnerI;
@@ -490,10 +491,13 @@ public class JalviewFileChooser extends JFileChooser
 
     if (selectedFile.exists())
     {
-      int confirm = JvOptionPane.showConfirmDialog(this,
-              MessageManager.getString("label.overwrite_existing_file"),
-              MessageManager.getString("label.file_already_exists"),
-              JvOptionPane.YES_NO_OPTION);
+      int confirm = Cache.getDefault("CONFIRM_OVERWRITE_FILE", true)
+              ? JvOptionPane.showConfirmDialog(this,
+                      MessageManager
+                              .getString("label.overwrite_existing_file"),
+                      MessageManager.getString("label.file_already_exists"),
+                      JvOptionPane.YES_NO_OPTION)
+              : JOptionPane.YES_OPTION;
 
       if (confirm != JvOptionPane.YES_OPTION)
       {
@@ -598,6 +602,24 @@ public class JalviewFileChooser extends JFileChooser
 
   }
 
+  /*
+  @Override
+  public JalviewFileChooser setResponseHandler(Object response,
+          Runnable action)
+  {
+    callbacks.put(response, new Callable<Void>()
+    {
+      @Override
+      public Void call()
+      {
+        action.run();
+        return null;
+      }
+    });
+    return this;
+  }
+  */
+
   @Override
   public DialogRunnerI setResponseHandler(Object response, Runnable action)
   {
@@ -618,7 +640,13 @@ public class JalviewFileChooser extends JFileChooser
     Runnable action = callbacks.get(response);
     if (action != null)
     {
-      action.run();
+      try
+      {
+        action.run();
+      } catch (Exception e)
+      {
+        e.printStackTrace();
+      }
     }
   }
 
@@ -648,7 +676,7 @@ public class JalviewFileChooser extends JFileChooser
   protected JDialog createDialog(Component parent) throws HeadlessException
   {
     JDialog dialog = super.createDialog(parent);
-    dialog.setIconImage(WindowIcons.logoIcon.getImage());
+    dialog.setIconImages(ChannelProperties.getIconList());
     return dialog;
   }