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 java.awt.event.*;
\r
23 import javax.swing.*;
\r
24 import javax.swing.event.*;
\r
26 public class GFinder
\r
29 JLabel jLabel1 = new JLabel();
\r
30 protected JButton findAll = new JButton();
\r
31 protected JButton findNext = new JButton();
\r
32 JPanel jPanel1 = new JPanel();
\r
33 GridLayout gridLayout1 = new GridLayout();
\r
34 protected JButton createNewGroup = new JButton();
\r
35 JScrollPane jScrollPane1 = new JScrollPane();
\r
36 protected JTextArea textfield = new JTextArea();
\r
37 BorderLayout borderLayout1 = new BorderLayout();
\r
38 JPanel jPanel2 = new JPanel();
\r
39 JPanel jPanel3 = new JPanel();
\r
40 JPanel jPanel4 = new JPanel();
\r
41 BorderLayout borderLayout2 = new BorderLayout();
\r
42 JPanel jPanel5 = new JPanel();
\r
43 JPanel jPanel6 = new JPanel();
\r
52 e.printStackTrace();
\r
56 private void jbInit()
\r
59 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
\r
60 jLabel1.setText("Find");
\r
61 this.setLayout(borderLayout1);
\r
62 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
\r
63 findAll.setText("Find all");
\r
64 findAll.addActionListener(new java.awt.event.ActionListener()
\r
66 public void actionPerformed(ActionEvent e)
\r
68 findAll_actionPerformed(e);
\r
71 findNext.setEnabled(false);
\r
72 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
\r
73 findNext.setText("Find Next");
\r
74 findNext.addActionListener(new java.awt.event.ActionListener()
\r
76 public void actionPerformed(ActionEvent e)
\r
78 findNext_actionPerformed(e);
\r
81 jPanel1.setLayout(gridLayout1);
\r
82 gridLayout1.setHgap(0);
\r
83 gridLayout1.setRows(3);
\r
84 gridLayout1.setVgap(2);
\r
85 createNewGroup.setEnabled(false);
\r
86 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
\r
87 createNewGroup.setToolTipText("");
\r
88 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
\r
89 createNewGroup.setText("Create new group");
\r
90 createNewGroup.addActionListener(new java.awt.event.ActionListener()
\r
92 public void actionPerformed(ActionEvent e)
\r
94 createNewGroup_actionPerformed(e);
\r
97 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
\r
98 textfield.setText("");
\r
99 textfield.setLineWrap(true);
\r
100 textfield.addCaretListener(new CaretListener()
\r
102 public void caretUpdate(CaretEvent e)
\r
104 textfield_caretUpdate(e);
\r
107 borderLayout1.setHgap(5);
\r
108 borderLayout1.setVgap(5);
\r
109 jPanel4.setLayout(borderLayout2);
\r
110 jPanel2.setPreferredSize(new Dimension(10, 1));
\r
111 jPanel3.setPreferredSize(new Dimension(10, 1));
\r
112 jPanel1.add(findNext, null);
\r
113 jPanel1.add(findAll, null);
\r
114 jPanel1.add(createNewGroup, null);
\r
115 this.add(jLabel1, java.awt.BorderLayout.WEST);
\r
116 this.add(jPanel1, java.awt.BorderLayout.EAST);
\r
117 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
\r
118 this.add(jPanel3, java.awt.BorderLayout.NORTH);
\r
119 this.add(jPanel4, java.awt.BorderLayout.CENTER);
\r
120 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
\r
121 jPanel4.add(jPanel5, java.awt.BorderLayout.SOUTH);
\r
122 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
\r
123 jScrollPane1.getViewport().add(textfield);
\r
126 protected void findNext_actionPerformed(ActionEvent e)
\r
130 protected void findAll_actionPerformed(ActionEvent e)
\r
134 protected void textfield_actionPerformed(ActionEvent e)
\r
138 void textfield_keyTyped(KeyEvent e)
\r
140 findNext.setEnabled(true);
\r
143 public void createNewGroup_actionPerformed(ActionEvent e)
\r
147 public void textfield_caretUpdate(CaretEvent e)
\r
149 if (textfield.getText().indexOf("\t") > -1)
\r
151 SwingUtilities.invokeLater(new Runnable()
\r
155 String text = textfield.getText();
\r
156 text = text.substring(text.lastIndexOf("\t") + 1).trim();
\r
157 text = jalview.analysis.AlignSeq.extractGaps(
\r
158 jalview.util.Comparison.GapChars, text);
\r
159 textfield.setText(text);
\r