2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.jbgui;
20 import jalview.gui.JvSwingUtils;
21 import jalview.util.UrlLink;
24 import java.awt.event.*;
27 public class GSequenceLink extends Panel
29 public GSequenceLink()
34 } catch (Exception ex)
40 private void jbInit() throws Exception
42 this.setLayout(gridBagLayout1);
43 nameTB.setFont(JvSwingUtils.getLabelFont());
44 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
45 nameTB.addKeyListener(new KeyAdapter()
47 public void keyTyped(KeyEvent e)
52 urlTB.setFont(JvSwingUtils.getLabelFont());
53 urlTB.setText("http://www.");
54 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
55 urlTB.addKeyListener(new KeyAdapter()
57 public void keyTyped(KeyEvent e)
62 jLabel1.setFont(JvSwingUtils.getLabelFont());
63 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
64 jLabel1.setText("Link Name");
65 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
66 jLabel2.setFont(JvSwingUtils.getLabelFont());
67 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
68 jLabel2.setText("URL");
69 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
70 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
71 jLabel3.setText("Use $SEQUENCE_ID$ or $SEQUENCE_ID=/<regex>/=$");
72 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
73 jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
74 jLabel4.setText("\nto embed sequence id in URL");
75 jLabel4.setBounds(new Rectangle(21, 93, 351, 15));
76 jPanel1.setBorder(BorderFactory.createEtchedBorder());
77 jPanel1.setLayout(null);
84 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
85 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
86 5, 4, 6, 5), 390, 130));
89 public void setName(String name)
94 public void setURL(String url)
99 public String getName()
101 return nameTB.getText();
104 public String getURL()
106 return urlTB.getText();
109 public boolean checkValid()
111 UrlLink ul = new UrlLink("foo|" + urlTB.getText().trim());
112 if (ul.isValid() && ul.isDynamic())
118 .showInternalMessageDialog(
119 jalview.gui.Desktop.desktop,
120 "Sequence URL must contain $SEQUENCE_ID$ or a regex $SEQUENCE_ID=/<regex>/=$",
121 "URL not valid", JOptionPane.WARNING_MESSAGE);
125 JTextField nameTB = new JTextField();
127 JTextField urlTB = new JTextField();
129 JLabel jLabel1 = new JLabel();
131 JLabel jLabel2 = new JLabel();
133 JLabel jLabel3 = new JLabel();
135 JLabel jLabel4 = new JLabel();
137 JPanel jPanel1 = new JPanel();
139 GridBagLayout gridBagLayout1 = new GridBagLayout();
141 public void nameTB_keyTyped(KeyEvent e)
143 if (e.getKeyChar() == '|')
149 public void urlTB_keyTyped(KeyEvent e)
151 // URLLink object validation takes care of incorrect regexes.
152 // if (e.getKeyChar() == '|' || e.getKeyChar() == ' ')