update author list in license for (JAL-826)
[jalview.git] / src / jalview / gui / EditNameDialog.java
index 2b1ee72..ecc78b0 100644 (file)
@@ -1,78 +1,82 @@
-/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
- */\r
-\r
-package jalview.gui;\r
-\r
-import java.awt.*;\r
-import javax.swing.*;\r
-\r
-public class EditNameDialog\r
-{\r
-  JTextField id, description;\r
-  JButton ok = new JButton("Accept");\r
-  JButton cancel = new JButton("Cancel");\r
-  boolean accept = false;\r
-\r
-\r
-  public String getName()\r
-  {\r
-    return id.getText();\r
-  }\r
-\r
-  public String getDescription()\r
-  {\r
-    if (description.getText().length() < 1)\r
-      return null;\r
-    else\r
-      return description.getText();\r
-  }\r
-\r
-  public EditNameDialog(String name,\r
-                        String desc,\r
-                        String label1,\r
-                        String label2,\r
-                        String title)\r
-  {\r
-    JLabel idlabel = new JLabel( label1);\r
-    JLabel desclabel = new JLabel(label2);\r
-    idlabel.setFont(new Font("Courier", Font.PLAIN, 12));\r
-    desclabel.setFont(new Font("Courier", Font.PLAIN, 12));\r
-    id = new JTextField(name, 40);\r
-    description = new JTextField(desc, 40);\r
-    JPanel panel = new JPanel(new BorderLayout());\r
-    JPanel panel2 = new JPanel(new BorderLayout());\r
-    panel2.add(idlabel, BorderLayout.WEST);\r
-    panel2.add(id, BorderLayout.CENTER);\r
-    panel.add(panel2, BorderLayout.NORTH);\r
-    panel2 = new JPanel(new BorderLayout());\r
-    panel2.add(desclabel, BorderLayout.WEST);\r
-    panel2.add(description, BorderLayout.CENTER);\r
-    panel.add(panel2, BorderLayout.SOUTH);\r
-\r
-\r
-     int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,\r
-        panel, title,\r
-        JOptionPane.OK_CANCEL_OPTION );\r
-\r
-     if (reply == JOptionPane.OK_OPTION)\r
-     {\r
-       accept = true;\r
-     }\r
-  }\r
-}\r
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * 
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package jalview.gui;
+
+import java.awt.*;
+import javax.swing.*;
+
+public class EditNameDialog
+{
+  JTextField id, description;
+
+  JButton ok = new JButton("Accept");
+
+  JButton cancel = new JButton("Cancel");
+
+  boolean accept = false;
+
+  public String getName()
+  {
+    return id.getText();
+  }
+
+  public String getDescription()
+  {
+    if (description.getText().length() < 1)
+    {
+      return null;
+    }
+    else
+    {
+      return description.getText();
+    }
+  }
+
+  public EditNameDialog(String name, String desc, String label1,
+          String label2, String title, JComponent parent)
+  {
+    JLabel idlabel = new JLabel(label1);
+    JLabel desclabel = new JLabel(label2);
+    idlabel.setFont(new Font("Courier", Font.PLAIN, 12));
+    desclabel.setFont(new Font("Courier", Font.PLAIN, 12));
+    id = new JTextField(name, 40);
+    description = new JTextField(desc, 40);
+    JPanel panel = new JPanel(new BorderLayout());
+    JPanel panel2 = new JPanel(new BorderLayout());
+    panel2.add(idlabel, BorderLayout.WEST);
+    panel2.add(id, BorderLayout.CENTER);
+    panel.add(panel2, BorderLayout.NORTH);
+    if (desc != null || label2 != null)
+    {
+      panel2 = new JPanel(new BorderLayout());
+      panel2.add(desclabel, BorderLayout.WEST);
+      panel2.add(description, BorderLayout.CENTER);
+      panel.add(panel2, BorderLayout.SOUTH);
+    }
+    int reply = JOptionPane.showInternalConfirmDialog(parent, panel, title,
+            JOptionPane.OK_CANCEL_OPTION);
+    if (!parent.requestFocusInWindow())
+    {
+      System.err.println("Bad focus for dialog!");
+    }
+    if (reply == JOptionPane.OK_OPTION)
+    {
+      accept = true;
+    }
+  }
+}