Merge branch 'features/r2_11_2_alphafold/JAL-629' into features/JAL-3858_PAEsInProjects
[jalview.git] / src / jalview / gui / JvOptionPane.java
index 364d4c1..0e0b13d 100644 (file)
@@ -57,6 +57,7 @@ import javax.swing.UIManager;
 import javax.swing.event.InternalFrameEvent;
 import javax.swing.event.InternalFrameListener;
 
+import jalview.util.ChannelProperties;
 import jalview.util.Platform;
 import jalview.util.dialogrunner.DialogRunnerI;
 
@@ -82,6 +83,7 @@ public class JvOptionPane extends JOptionPane
   public JvOptionPane(final Component parent)
   {
     this.parentComponent = Platform.isJS() ? this : parent;
+    this.setIcon(null);
   }
 
   public static int showConfirmDialog(Component parentComponent,
@@ -803,6 +805,7 @@ public class JvOptionPane extends JOptionPane
     if (!isInteractiveMode())
     {
       handleResponse(getMockResponse());
+      return;
     }
     // two uses:
     //
@@ -1028,7 +1031,7 @@ public class JvOptionPane extends JOptionPane
               Platform.isJS() ? initialValue : initialValue_btn);
 
       JDialog dialog = joptionpane.createDialog(parentComponent, title);
-      dialog.setIconImage(WindowIcons.logoIcon.getImage());
+      dialog.setIconImages(ChannelProperties.getIconList());
       dialog.setModalityType(modal ? ModalityType.APPLICATION_MODAL
               : ModalityType.MODELESS);
       dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
@@ -1058,7 +1061,7 @@ public class JvOptionPane extends JOptionPane
     if (parentComponent != this)
     {
       JInternalFrame jif = this.createInternalFrame(parentComponent, title);
-      jif.setFrameIcon(WindowIcons.logoIcon);
+      jif.setFrameIcon(null);
       jif.addInternalFrameListener(new InternalFrameListener()
       {
         @Override
@@ -1104,7 +1107,7 @@ public class JvOptionPane extends JOptionPane
     else
     {
       JDialog dialog = this.createDialog(parentComponent, title);
-      dialog.setIconImage(WindowIcons.logoIcon.getImage());
+      dialog.setIconImages(ChannelProperties.getIconList());
       dialog.setVisible(true); // blocking
       this.internalDialogHandleResponse();
       return;
@@ -1149,6 +1152,10 @@ public class JvOptionPane extends JOptionPane
   public static int showDialogOnTop(String label, String actionString,
           int JOPTIONPANE_OPTION, int JOPTIONPANE_MESSAGETYPE)
   {
+    if (!isInteractiveMode())
+    {
+      return (int) getMockResponse();
+    }
     // Ensure Jalview window is brought to front (primarily for Quit
     // confirmation window to be visible)
 
@@ -1159,7 +1166,7 @@ public class JvOptionPane extends JOptionPane
     // A better hack which works is to create a new JFrame parent with
     // setAlwaysOnTop(true)
     JFrame dialogParent = new JFrame();
-    dialogParent.setIconImage(WindowIcons.logoIcon.getImage());
+    dialogParent.setIconImages(ChannelProperties.getIconList());
     dialogParent.setAlwaysOnTop(true);
 
     int answer = JOptionPane.showConfirmDialog(dialogParent, label,
@@ -1176,7 +1183,7 @@ public class JvOptionPane extends JOptionPane
           Object[] options, Object initialValue, boolean modal)
   {
     JFrame frame = new JFrame();
-    frame.setIconImage(WindowIcons.logoIcon.getImage());
+    frame.setIconImages(ChannelProperties.getIconList());
     showDialogOnTopAsync(frame, label, actionString, JOPTIONPANE_OPTION,
             JOPTIONPANE_MESSAGETYPE, icon, options, initialValue, modal);
   }
@@ -1196,6 +1203,11 @@ public class JvOptionPane extends JOptionPane
           int JOPTIONPANE_MESSAGETYPE, Icon icon, Object[] options,
           Object initialValue, boolean modal, JButton[] buttons)
   {
+    if (!isInteractiveMode())
+    {
+      handleResponse(getMockResponse());
+      return;
+    }
     // Ensure Jalview window is brought to front (primarily for Quit
     // confirmation window to be visible)
 
@@ -1280,6 +1292,11 @@ public class JvOptionPane extends JOptionPane
           Object[] options, Object initialValue, boolean modal,
           JButton[] buttons)
   {
+    if (!isInteractiveMode())
+    {
+      handleResponse(getMockResponse());
+      return null;
+    }
     JButton[] optionsButtons = null;
     Object initialValueButton = null;
     JOptionPane joptionpane = new JOptionPane();
@@ -1391,7 +1408,7 @@ public class JvOptionPane extends JOptionPane
             Platform.isJS() ? initialValue : initialValueButton);
 
     JDialog dialog = joptionpane.createDialog(parentComponent, title);
-    dialog.setIconImage(WindowIcons.logoIcon.getImage());
+    dialog.setIconImages(ChannelProperties.getIconList());
     dialog.setModalityType(
             modal ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
     dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);