2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.jbgui;
21 import jalview.util.UrlLink;
24 import java.awt.event.*;
27 public class GSequenceLink
30 public GSequenceLink()
45 this.setLayout(gridBagLayout1);
46 nameTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
47 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
48 nameTB.addKeyListener(new KeyAdapter()
50 public void keyTyped(KeyEvent e)
55 urlTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
56 urlTB.setText("http://www.");
57 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
58 urlTB.addKeyListener(new KeyAdapter()
60 public void keyTyped(KeyEvent e)
65 jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
66 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
67 jLabel1.setText("Link Name");
68 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
69 jLabel2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
70 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
71 jLabel2.setText("URL");
72 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
73 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
74 jLabel3.setText("Use $SEQUENCE_ID$ or $SEQUENCE_ID=/<regex>/=$");
75 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
76 jLabel4.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
77 jLabel4.setText("\nto embed sequence id in URL");
78 jLabel4.setBounds(new Rectangle(21, 93, 351, 15));
79 jPanel1.setBorder(BorderFactory.createEtchedBorder());
80 jPanel1.setLayout(null);
87 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
88 , GridBagConstraints.CENTER,
89 GridBagConstraints.BOTH,
90 new Insets(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())
121 JOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
122 "Sequence URL must contain $SEQUENCE_ID$ or a regex $SEQUENCE_ID=/<regex>/=$",
124 JOptionPane.WARNING_MESSAGE);
128 JTextField nameTB = new JTextField();
129 JTextField urlTB = new JTextField();
130 JLabel jLabel1 = new JLabel();
131 JLabel jLabel2 = new JLabel();
132 JLabel jLabel3 = new JLabel();
133 JLabel jLabel4 = new JLabel();
134 JPanel jPanel1 = new JPanel();
135 GridBagLayout gridBagLayout1 = new GridBagLayout();
136 public void nameTB_keyTyped(KeyEvent e)
138 if (e.getKeyChar() == '|')
144 public void urlTB_keyTyped(KeyEvent e)
146 // URLLink object validation takes care of incorrect regexes.
147 //if (e.getKeyChar() == '|' || e.getKeyChar() == ' ')