2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
23 import jalview.gui.JvOptionPane;
24 import jalview.gui.JvSwingUtils;
25 import jalview.util.MessageManager;
26 import jalview.util.UrlLink;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.Insets;
32 import java.awt.Panel;
33 import java.awt.Rectangle;
34 import java.awt.event.KeyAdapter;
35 import java.awt.event.KeyEvent;
37 import javax.swing.BorderFactory;
38 import javax.swing.JLabel;
39 import javax.swing.JPanel;
40 import javax.swing.JTextField;
41 import javax.swing.SwingConstants;
43 public class GSequenceLink extends Panel
45 public GSequenceLink()
50 } catch (Exception ex)
56 private void jbInit() throws Exception
58 this.setLayout(gridBagLayout1);
59 nameTB.setFont(JvSwingUtils.getLabelFont());
60 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
61 nameTB.addKeyListener(new KeyAdapter()
64 public void keyTyped(KeyEvent e)
69 urlTB.setFont(JvSwingUtils.getLabelFont());
70 urlTB.setText("http://");
71 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
72 urlTB.addKeyListener(new KeyAdapter()
75 public void keyTyped(KeyEvent e)
80 jLabel1.setFont(JvSwingUtils.getLabelFont());
81 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
82 jLabel1.setText(MessageManager.getString("label.link_name"));
83 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
84 jLabel2.setFont(JvSwingUtils.getLabelFont());
85 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
86 jLabel2.setText(MessageManager.getString("label.url"));
87 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
88 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
89 jLabel3.setText(MessageManager.getString("label.use_sequence_id_1"));
90 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
91 jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
92 jLabel4.setText(MessageManager.getString("label.use_sequence_id_2"));
93 jLabel4.setBounds(new Rectangle(21, 88, 351, 15));
94 jLabel5.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
95 jLabel5.setText(MessageManager.getString("label.use_sequence_id_3"));
96 jLabel5.setBounds(new Rectangle(21, 106, 351, 15));
98 String lastLabel = MessageManager.getString("label.use_sequence_id_4");
99 if (lastLabel.length() > 0)
101 // e.g. Spanish version has longer text
102 jLabel6.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
103 jLabel6.setText(lastLabel);
104 jLabel6.setBounds(new Rectangle(21, 122, 351, 15));
107 jPanel1.setBorder(BorderFactory.createEtchedBorder());
108 jPanel1.setLayout(null);
109 jPanel1.add(jLabel1);
112 jPanel1.add(jLabel2);
113 jPanel1.add(jLabel3);
114 jPanel1.add(jLabel4);
115 jPanel1.add(jLabel5);
118 if (lastLabel.length() > 0)
120 jPanel1.add(jLabel6);
124 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
125 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
126 5, 4, 6, 5), 390, height));
130 public void setName(String name)
132 nameTB.setText(name);
135 public void setURL(String url)
141 public String getName()
143 return nameTB.getText();
146 public String getURL()
148 return urlTB.getText();
151 public boolean checkValid()
153 UrlLink ul = new UrlLink("foo|" + urlTB.getText().trim());
154 if (ul.isValid() && ul.isDynamic())
159 JvOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
160 MessageManager.getString("warn.url_must_contain"),
161 MessageManager.getString("label.invalid_url"),
162 JvOptionPane.WARNING_MESSAGE);
166 JTextField nameTB = new JTextField();
168 JTextField urlTB = new JTextField();
170 JLabel jLabel1 = new JLabel();
172 JLabel jLabel2 = new JLabel();
174 JLabel jLabel3 = new JLabel();
176 JLabel jLabel4 = new JLabel();
178 JLabel jLabel5 = new JLabel();
180 JLabel jLabel6 = new JLabel();
182 JPanel jPanel1 = new JPanel();
184 GridBagLayout gridBagLayout1 = new GridBagLayout();
186 public void nameTB_keyTyped(KeyEvent e)
188 if (e.getKeyChar() == '|')
194 public void urlTB_keyTyped(KeyEvent e)
196 // URLLink object validation takes care of incorrect regexes.
197 // if (e.getKeyChar() == '|' || e.getKeyChar() == ' ')