2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.jbgui;
\r
22 import javax.swing.JTextField;
\r
23 import javax.swing.JLabel;
\r
24 import javax.swing.*;
\r
25 import java.awt.event.KeyAdapter;
\r
26 import java.awt.event.KeyEvent;
\r
28 public class GSequenceLink
\r
31 public GSequenceLink()
\r
37 catch (Exception ex)
\r
39 ex.printStackTrace();
\r
43 private void jbInit()
\r
46 this.setLayout(gridBagLayout1);
\r
47 nameTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
\r
48 nameTB.setBounds(new Rectangle(77, 10, 310, 23));
\r
49 nameTB.addKeyListener(new KeyAdapter()
\r
51 public void keyTyped(KeyEvent e)
\r
56 urlTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
\r
57 urlTB.setText("http://www.");
\r
58 urlTB.setBounds(new Rectangle(78, 40, 309, 23));
\r
59 urlTB.addKeyListener(new KeyAdapter()
\r
61 public void keyTyped(KeyEvent e)
\r
66 jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
\r
67 jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
\r
68 jLabel1.setText("Link Name");
\r
69 jLabel1.setBounds(new Rectangle(4, 10, 71, 24));
\r
70 jLabel2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
\r
71 jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
\r
72 jLabel2.setText("URL");
\r
73 jLabel2.setBounds(new Rectangle(17, 37, 54, 27));
\r
74 jLabel3.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
\r
75 jLabel3.setText("Use $SEQUENCE_ID$ to specify where sequence id is in URL");
\r
76 jLabel3.setBounds(new Rectangle(21, 72, 351, 15));
\r
77 jPanel1.setBorder(BorderFactory.createEtchedBorder());
\r
78 jPanel1.setLayout(null);
\r
79 jPanel1.add(jLabel1);
\r
80 jPanel1.add(nameTB);
\r
82 jPanel1.add(jLabel2);
\r
83 jPanel1.add(jLabel3);
\r
84 this.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
\r
85 , GridBagConstraints.CENTER,
\r
86 GridBagConstraints.BOTH,
\r
87 new Insets(5, 4, 6, 5), 390, 100));
\r
90 public void setName(String name)
\r
92 nameTB.setText(name);
\r
95 public void setURL(String url)
\r
100 public String getName()
\r
102 return nameTB.getText();
\r
105 public String getURL()
\r
107 return urlTB.getText();
\r
110 public boolean checkValid()
\r
112 if(urlTB.getText().indexOf("$SEQUENCE_ID$")==-1)
\r
114 JOptionPane.showInternalMessageDialog(jalview.gui.Desktop.desktop,
\r
115 "Sequence URL must contain $SEQUENCE_ID$",
\r
116 "URL not valid", JOptionPane.WARNING_MESSAGE);
\r
124 JTextField nameTB = new JTextField();
\r
125 JTextField urlTB = new JTextField();
\r
126 JLabel jLabel1 = new JLabel();
\r
127 JLabel jLabel2 = new JLabel();
\r
128 JLabel jLabel3 = new JLabel();
\r
129 JPanel jPanel1 = new JPanel();
\r
130 GridBagLayout gridBagLayout1 = new GridBagLayout();
\r
131 public void nameTB_keyTyped(KeyEvent e)
\r
133 if(e.getKeyChar()=='|')
\r
139 public void urlTB_keyTyped(KeyEvent e)
\r
141 if (e.getKeyChar() == '|' || e.getKeyChar()==' ')
\r