2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.event.*;
31 public class GSequenceLink extends Panel
33 public GSequenceLink()
38 } catch (Exception ex)
44 private void jbInit() throws Exception
46 this.setLayout(gridBagLayout1);
47 nameTB.setFont(JvSwingUtils.getLabelFont());
48 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
49 nameTB.addKeyListener(new KeyAdapter()
51 public void keyTyped(KeyEvent e)
56 urlTB.setFont(JvSwingUtils.getLabelFont());
57 urlTB.setText("http://www.");
58 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
59 urlTB.addKeyListener(new KeyAdapter()
61 public void keyTyped(KeyEvent e)
66 jLabel1.setFont(JvSwingUtils.getLabelFont());
67 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
68 jLabel1.setText(MessageManager.getString("label.link_name"));
69 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
70 jLabel2.setFont(JvSwingUtils.getLabelFont());
71 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
72 jLabel2.setText(MessageManager.getString("label.url"));
73 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
74 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
75 jLabel3.setText(MessageManager.getString("label.use_sequence_id_1"));
76 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
77 jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
78 jLabel4.setText(MessageManager.getString("label.use_sequence_id_2"));
79 jLabel4.setBounds(new Rectangle(21, 93, 351, 15));
80 jPanel1.setBorder(BorderFactory.createEtchedBorder());
81 jPanel1.setLayout(null);
88 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
89 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
90 5, 4, 6, 5), 390, 130));
93 public void setName(String name)
98 public void setURL(String url)
103 public String getName()
105 return nameTB.getText();
108 public String getURL()
110 return urlTB.getText();
113 public boolean checkValid()
115 UrlLink ul = new UrlLink("foo|" + urlTB.getText().trim());
116 if (ul.isValid() && ul.isDynamic())
122 .showInternalMessageDialog(
123 jalview.gui.Desktop.desktop,
124 MessageManager.getString("warn.url_must_contain"),
125 MessageManager.getString("label.invalid_url"), JOptionPane.WARNING_MESSAGE);
129 JTextField nameTB = new JTextField();
131 JTextField urlTB = new JTextField();
133 JLabel jLabel1 = new JLabel();
135 JLabel jLabel2 = new JLabel();
137 JLabel jLabel3 = new JLabel();
139 JLabel jLabel4 = new JLabel();
141 JPanel jPanel1 = new JPanel();
143 GridBagLayout gridBagLayout1 = new GridBagLayout();
145 public void nameTB_keyTyped(KeyEvent e)
147 if (e.getKeyChar() == '|')
153 public void urlTB_keyTyped(KeyEvent e)
155 // URLLink object validation takes care of incorrect regexes.
156 // if (e.getKeyChar() == '|' || e.getKeyChar() == ' ')