2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 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;
22 import javax.swing.JTextField;
23 import javax.swing.JLabel;
25 import java.awt.event.KeyAdapter;
26 import java.awt.event.KeyEvent;
28 public class GSequenceLink
31 public GSequenceLink()
46 this.setLayout(gridBagLayout1);
47 nameTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
48 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
49 nameTB.addKeyListener(new KeyAdapter()
51 public void keyTyped(KeyEvent e)
56 urlTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
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(new java.awt.Font("Verdana", Font.PLAIN, 11));
67 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
68 jLabel1.setText("Link Name");
69 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
70 jLabel2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
71 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
72 jLabel2.setText("URL");
73 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
74 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
75 jLabel3.setText("Use $SEQUENCE_ID$ to specify where sequence id is in URL");
76 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
77 jPanel1.setBorder(BorderFactory.createEtchedBorder());
78 jPanel1.setLayout(null);
84 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
85 , GridBagConstraints.CENTER,
86 GridBagConstraints.BOTH,
87 new Insets(5, 4, 6, 5), 390, 100));
90 public void setName(String name)
95 public void setURL(String url)
100 public String getName()
102 return nameTB.getText();
105 public String getURL()
107 return urlTB.getText();
110 public boolean checkValid()
112 if(urlTB.getText().indexOf("$SEQUENCE_ID$")==-1)
114 JOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
115 "Sequence URL must contain $SEQUENCE_ID$",
116 "URL not valid", JOptionPane.WARNING_MESSAGE);
124 JTextField nameTB = new JTextField();
125 JTextField urlTB = new JTextField();
126 JLabel jLabel1 = new JLabel();
127 JLabel jLabel2 = new JLabel();
128 JLabel jLabel3 = new JLabel();
129 JPanel jPanel1 = new JPanel();
130 GridBagLayout gridBagLayout1 = new GridBagLayout();
131 public void nameTB_keyTyped(KeyEvent e)
133 if(e.getKeyChar()=='|')
139 public void urlTB_keyTyped(KeyEvent e)
141 if (e.getKeyChar() == '|' || e.getKeyChar()==' ')