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.Desktop;
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.JOptionPane;
40 import javax.swing.JPanel;
41 import javax.swing.JTextField;
42 import javax.swing.SwingConstants;
44 public class GSequenceLink extends Panel
46 public GSequenceLink()
51 } catch (Exception ex)
57 private void jbInit() throws Exception
59 this.setLayout(gridBagLayout1);
60 nameTB.setFont(JvSwingUtils.getLabelFont());
61 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
62 nameTB.addKeyListener(new KeyAdapter()
64 public void keyTyped(KeyEvent e)
69 urlTB.setFont(JvSwingUtils.getLabelFont());
70 urlTB.setText("http://www.");
71 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
72 urlTB.addKeyListener(new KeyAdapter()
74 public void keyTyped(KeyEvent e)
79 jLabel1.setFont(JvSwingUtils.getLabelFont());
80 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
81 jLabel1.setText(MessageManager.getString("label.link_name"));
82 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
83 jLabel2.setFont(JvSwingUtils.getLabelFont());
84 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
85 jLabel2.setText(MessageManager.getString("label.url"));
86 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
87 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
88 jLabel3.setText(MessageManager.getString("label.use_sequence_id_1"));
89 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
90 jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
91 jLabel4.setText(MessageManager.getString("label.use_sequence_id_2"));
92 jLabel4.setBounds(new Rectangle(21, 93, 351, 15));
93 jPanel1.setBorder(BorderFactory.createEtchedBorder());
94 jPanel1.setLayout(null);
100 jPanel1.add(jLabel4);
101 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
102 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
103 5, 4, 6, 5), 390, 130));
106 public void setName(String name)
108 nameTB.setText(name);
111 public void setURL(String url)
116 public String getName()
118 return nameTB.getText();
121 public String getURL()
123 return urlTB.getText();
126 public boolean checkValid()
128 UrlLink ul = new UrlLink("foo|" + urlTB.getText().trim());
129 if (ul.isValid() && ul.isDynamic())
135 .showInternalMessageDialog(Desktop.desktop,
136 MessageManager.getString("warn.url_must_contain"),
137 MessageManager.getString("label.invalid_url"), JOptionPane.WARNING_MESSAGE);
141 JTextField nameTB = new JTextField();
143 JTextField urlTB = new JTextField();
145 JLabel jLabel1 = new JLabel();
147 JLabel jLabel2 = new JLabel();
149 JLabel jLabel3 = new JLabel();
151 JLabel jLabel4 = new JLabel();
153 JPanel jPanel1 = new JPanel();
155 GridBagLayout gridBagLayout1 = new GridBagLayout();
157 public void nameTB_keyTyped(KeyEvent e)
159 if (e.getKeyChar() == '|')
165 public void urlTB_keyTyped(KeyEvent e)
167 // URLLink object validation takes care of incorrect regexes.
168 // if (e.getKeyChar() == '|' || e.getKeyChar() == ' ')