X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FJvOptionPane.java;fp=src%2Fjalview%2Fgui%2FJvOptionPane.java;h=9b0d0986acead493e48fd55a363f362c8d3212ab;hb=8f31ab72a635fbc5c648a5205ffb62059ca1b78b;hp=99ab26f7cd419decd6c3c519e23e57f95c227356;hpb=b81011230fbb6ed9286b4d1a7136a4535978e3db;p=jalview.git diff --git a/src/jalview/gui/JvOptionPane.java b/src/jalview/gui/JvOptionPane.java index 99ab26f..9b0d098 100644 --- a/src/jalview/gui/JvOptionPane.java +++ b/src/jalview/gui/JvOptionPane.java @@ -73,6 +73,10 @@ public class JvOptionPane extends JOptionPane private static boolean interactiveMode = true; + public static final Callable NULLCALLABLE = () -> { + return null; + }; + private Component parentComponent; private ExecutorService executor = Executors.newCachedThreadPool(); @@ -1048,7 +1052,7 @@ public class JvOptionPane extends JOptionPane } } - public void showInternalDialog(JPanel mainPanel, String title, + public void showInternalDialog(Object mainPanel, String title, int yesNoCancelOption, int questionMessage, Icon icon, Object[] options, String initresponse) { @@ -1066,7 +1070,6 @@ public class JvOptionPane extends JOptionPane this.setMessage(mainPanel); ourOptions = Arrays.asList(options); - int response; if (parentComponent != this && !(parentComponent == null && Desktop.instance == null)) { @@ -1153,6 +1156,10 @@ public class JvOptionPane extends JOptionPane public JvOptionPane setResponseHandler(Object response, Callable action) { + if (action == null) + { + action = NULLCALLABLE; + } callbacks.put(response, action); return this; } @@ -1160,7 +1167,7 @@ public class JvOptionPane extends JOptionPane public ExecutorService getExecutor() { if (executor == null) - executor = Executors.newSingleThreadExecutor(); + executor = Executors.newCachedThreadPool(); return executor; } @@ -1553,9 +1560,9 @@ public class JvOptionPane extends JOptionPane } } - public static JvOptionPane frameDialog(String message, String title, + public static JvOptionPane frameDialog(Object message, String title, int messageType, String[] buttonsTextS, String defaultButtonS, - Callable[] handlers, boolean modal) + List> handlers, boolean modal) { JFrame parent = new JFrame(); JvOptionPane jvop = JvOptionPane.newOptionDialog(); @@ -1595,24 +1602,21 @@ public class JvOptionPane extends JOptionPane { dialogType = JOptionPane.YES_NO_CANCEL_OPTION; } - Callable nullCallable = () -> { - return null; - }; jvop.setResponseHandler(JOptionPane.YES_OPTION, - (handlers != null && handlers.length > 0) ? handlers[0] - : nullCallable); + (handlers != null && handlers.size() > 0) ? handlers.get(0) + : NULLCALLABLE); if (dialogType == JOptionPane.YES_NO_OPTION || dialogType == JOptionPane.YES_NO_CANCEL_OPTION) { jvop.setResponseHandler(JOptionPane.NO_OPTION, - (handlers != null && handlers.length > 1) ? handlers[1] - : nullCallable); + (handlers != null && handlers.size() > 1) ? handlers.get(1) + : NULLCALLABLE); } if (dialogType == JOptionPane.YES_NO_CANCEL_OPTION) { jvop.setResponseHandler(JOptionPane.CANCEL_OPTION, - (handlers != null && handlers.length > 2) ? handlers[2] - : nullCallable); + (handlers != null && handlers.size() > 2) ? handlers.get(2) + : NULLCALLABLE); } final int dt = dialogType;