JAL-4186 attempts to work in jalviewjs, still not working
[jalview.git] / src / jalview / gui / EditNameDialog.java
index e150b89..d61177c 100644 (file)
  */
 package jalview.gui;
 
-import jalview.util.MessageManager;
-import jalview.util.dialogrunner.RunResponse;
-
 import java.awt.FlowLayout;
 import java.awt.Font;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
 
 import javax.swing.BoxLayout;
 import javax.swing.JButton;
@@ -33,6 +33,8 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 
+import jalview.util.MessageManager;
+
 /**
  * A dialog where a name and description may be edited
  */
@@ -40,6 +42,7 @@ public class EditNameDialog
 {
   private static final Font COURIER_12 = new Font("Courier", Font.PLAIN,
           12);
+
   JTextField id;
 
   JTextField description;
@@ -86,7 +89,7 @@ public class EditNameDialog
     panel.add(descriptionPanel);
 
     JLabel nameLabel = new JLabel(label1);
-    nameLabel.setFont(COURIER_12);
+    // nameLabel.setFont(COURIER_12);
     namePanel.add(nameLabel);
 
     id = new JTextField(name, 40);
@@ -100,28 +103,36 @@ public class EditNameDialog
     if (desc != null || label2 != null)
     {
       JLabel descLabel = new JLabel(label2);
-      descLabel.setFont(COURIER_12);
+      // descLabel.setFont(COURIER_12);
       descriptionPanel.add(descLabel);
       descriptionPanel.add(description);
     }
   }
 
   /**
-   * Shows the dialog, and runs the response action if OK is selected. Note the
-   * RunResponse should be constructed to act on dialog return value
-   * JvOptionPane.OK_OPTION.
+   * Shows the dialog, and runs the response action if OK is selected
    * 
    * @param action
    */
   public void showDialog(JComponent parent, String title,
-          RunResponse action)
+          Callable<Void> action)
   {
-    Object[] options = new Object[] { MessageManager.getString("action.ok"),
-        MessageManager.getString("action.cancel") };
-    JvOptionPane.newOptionDialog(parent).response(action)
-            .showInternalDialog(panel, title,
-                    JvOptionPane.YES_NO_CANCEL_OPTION,
-                    JvOptionPane.PLAIN_MESSAGE, null, options,
-                    MessageManager.getString("action.ok"));
+    String ok = MessageManager.getString("action.ok");
+    String cancel = MessageManager.getString("action.cancel");
+    String[] options = new String[] { ok, cancel };
+
+    /*
+    JvOptionPane.newOptionDialog(parent)
+            .setResponseHandler(JvOptionPane.OK_OPTION, action)
+            .showInternalDialog(panel, title, JvOptionPane.OK_CANCEL_OPTION,
+                    JvOptionPane.PLAIN_MESSAGE, null, options, ok);
+            */
+
+    List<Callable<Void>> actions = new ArrayList<>();
+    actions.add(action);
+    actions.add(JvOptionPane.NULLCALLABLE);
+
+    JvOptionPane.frameDialog(panel, title, JvOptionPane.PLAIN_MESSAGE,
+            options, ok, actions, false);
   }
 }