4f1ce84b587a974cfaa0cd1e527cc843dfae97bc
[jalview.git] / src / jalview / appletgui / EditNameDialog.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.appletgui;
22
23 import java.awt.*;
24
25 public class EditNameDialog extends JVDialog
26 {
27   TextField id, description;
28
29   public String getName()
30   {
31     return id.getText();
32   }
33
34   public String getDescription()
35   {
36     if (description.getText().length() < 1)
37     {
38       return null;
39     }
40     else
41     {
42       return description.getText();
43     }
44   }
45
46   public EditNameDialog(String name, String desc, String label1,
47           String label2, Frame owner, String title, int width, int height,
48           boolean display)
49   {
50     super(owner, title, true, width, height);
51
52     Font mono = new Font("Monospaced", Font.PLAIN, 12);
53     Panel panel = new Panel(new BorderLayout());
54     Panel panel2 = new Panel(new BorderLayout());
55
56     id = new TextField(name, 40);
57     id.setFont(mono);
58     Label label = new Label(label1);
59     label.setFont(mono);
60
61     panel2.add(label, BorderLayout.WEST);
62     panel2.add(id, BorderLayout.CENTER);
63     panel.add(panel2, BorderLayout.NORTH);
64
65     if (label2 != null)
66     {
67       panel2 = new Panel(new BorderLayout());
68       description = new TextField(desc, 40);
69       description.setFont(mono);
70       label = new Label(label2);
71       label.setFont(mono);
72       panel2.add(label, BorderLayout.WEST);
73       panel2.add(description, BorderLayout.CENTER);
74       panel.add(panel2, BorderLayout.CENTER);
75     }
76     setMainPanel(panel);
77     setVisible(display);
78   }
79 }