JAL-3058 provide cancel callback method for colour chooser
[jalview.git] / src / jalview / gui / JvOptionPane.java
index 4e443e7..3a5e0f7 100644 (file)
@@ -34,6 +34,7 @@ import java.util.List;
 
 import javax.swing.Icon;
 import javax.swing.JOptionPane;
+import javax.swing.JPanel;
 
 public class JvOptionPane extends JOptionPane
         implements DialogRunnerI, PropertyChangeListener
@@ -481,6 +482,25 @@ public class JvOptionPane extends JOptionPane
   }
 
   /**
+   * adds inital selection value
+   * 
+   * @param message
+   * @param initialSelectionValue
+   * @return
+   */
+  public static String showInputDialog(Object message,
+          Object initialSelectionValue)
+  {
+    if (!isInteractiveMode())
+    {
+      return getMockResponse().toString();
+    }
+
+    // AnnotationPanel character option
+
+    return JOptionPane.showInputDialog(message, initialSelectionValue);
+  }
+  /**
    * centered on parent
    * 
    * @param parentComponent
@@ -517,6 +537,27 @@ public class JvOptionPane extends JOptionPane
                     initialSelectionValue)
             : getMockResponse().toString();
   }
+  
+
+  /**
+   * input with initial selection
+   * 
+   * @param parentComponent
+   * @param message
+   * @param initialSelectionValue
+   * @return
+   */
+  public static String showInputDialog(Component parentComponent,
+          Object message, Object initialSelectionValue)
+  {
+    
+    // AnnotationPanel
+    
+    return isInteractiveMode()
+            ? JOptionPane.showInputDialog(parentComponent, message,
+                    initialSelectionValue)
+            : getMockResponse().toString();
+  }
 
   /**
    * 
@@ -759,6 +800,45 @@ public class JvOptionPane extends JOptionPane
 
   }
 
+  public void showInternalDialog(JPanel mainPanel, String title,
+          int yesNoCancelOption, int questionMessage, Icon icon,
+          Object[] options, String initresponse)
+  {
+    if (!isInteractiveMode())
+    {
+      runner.firstRun((int) getMockResponse());
+    }
+    Component parent;
+    /**
+     * @j2sNative parent = this;
+     */
+    {
+      parent = parentComponent;
+    }
+    ;
+    ourOptions = Arrays.asList(options);
+    
+    int response;
+    if (parent!=this) {
+
+      response = JOptionPane.showInternalOptionDialog(parent, mainPanel,
+              title, yesNoCancelOption, questionMessage, icon, options,
+              initresponse);
+    }
+    else
+    {
+      response = JOptionPane.showOptionDialog(parent, mainPanel, title,
+              yesNoCancelOption, questionMessage, icon, options,
+              initresponse);
+    }
+    /**
+     * @j2sNative
+     */
+    {
+      runner.firstRun(response);
+    }
+    
+  }
   @Override
   public JvOptionPane response(RunResponse action)
   {
@@ -788,4 +868,5 @@ public class JvOptionPane extends JOptionPane
     }
   }
 
+
 }