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.JvSwingUtils;
24 import jalview.util.MessageManager;
25 import jalview.util.UrlLink;
28 import java.awt.GridBagConstraints;
29 import java.awt.GridBagLayout;
30 import java.awt.Insets;
31 import java.awt.Panel;
32 import java.awt.Rectangle;
33 import java.awt.event.KeyAdapter;
34 import java.awt.event.KeyEvent;
36 import javax.swing.BorderFactory;
37 import javax.swing.JLabel;
38 import javax.swing.JOptionPane;
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()
63 public void keyTyped(KeyEvent e)
68 urlTB.setFont(JvSwingUtils.getLabelFont());
69 urlTB.setText("http://www.");
70 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
71 urlTB.addKeyListener(new KeyAdapter()
73 public void keyTyped(KeyEvent e)
78 jLabel1.setFont(JvSwingUtils.getLabelFont());
79 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
80 jLabel1.setText(MessageManager.getString("label.link_name"));
81 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
82 jLabel2.setFont(JvSwingUtils.getLabelFont());
83 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
84 jLabel2.setText(MessageManager.getString("label.url"));
85 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
86 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
87 jLabel3.setText(MessageManager.getString("label.use_sequence_id_1"));
88 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
89 jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
90 jLabel4.setText(MessageManager.getString("label.use_sequence_id_2"));
91 jLabel4.setBounds(new Rectangle(21, 93, 351, 15));
92 jPanel1.setBorder(BorderFactory.createEtchedBorder());
93 jPanel1.setLayout(null);
100 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
101 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
102 5, 4, 6, 5), 390, 130));
105 public void setName(String name)
107 nameTB.setText(name);
110 public void setURL(String url)
115 public String getName()
117 return nameTB.getText();
120 public String getURL()
122 return urlTB.getText();
125 public boolean checkValid()
127 UrlLink ul = new UrlLink("foo|" + urlTB.getText().trim());
128 if (ul.isValid() && ul.isDynamic())
133 JOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
134 MessageManager.getString("warn.url_must_contain"),
135 MessageManager.getString("label.invalid_url"),
136 JOptionPane.WARNING_MESSAGE);
140 JTextField nameTB = new JTextField();
142 JTextField urlTB = new JTextField();
144 JLabel jLabel1 = new JLabel();
146 JLabel jLabel2 = new JLabel();
148 JLabel jLabel3 = new JLabel();
150 JLabel jLabel4 = new JLabel();
152 JPanel jPanel1 = new JPanel();
154 GridBagLayout gridBagLayout1 = new GridBagLayout();
156 public void nameTB_keyTyped(KeyEvent e)
158 if (e.getKeyChar() == '|')
164 public void urlTB_keyTyped(KeyEvent e)
166 // URLLink object validation takes care of incorrect regexes.
167 // if (e.getKeyChar() == '|' || e.getKeyChar() == ' ')