//////////////////////////////////////////////////////////////////
package jalview.io;
+import jalview.bin.Cache;
+import jalview.gui.JvOptionPane;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.util.dialogrunner.DialogRunnerI;
+
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.concurrent.Callable;
import javax.swing.BoxLayout;
import javax.swing.DefaultListCellRenderer;
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;
{
private static final long serialVersionUID = 1L;
- private Map<Object, Runnable> callbacks = new HashMap<>();
+ private Map<Object, Callable> callbacks = new HashMap<>();
File selectedFile = null;
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)
{
}
+ /*
+ @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)
+ public DialogRunnerI setResponseHandler(Object response, Callable action)
{
callbacks.put(response, action);
return this;
{
return;
}
- Runnable action = callbacks.get(response);
+ Callable action = callbacks.get(response);
if (action != null)
{
- action.run();
+ try
+ {
+ action.call();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
}