2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
24 import java.awt.event.*;
26 import javax.swing.event.*;
28 import jalview.datamodel.*;
30 import jalview.util.MessageManager;
32 public class GFinder extends JPanel
34 JLabel jLabel1 = new JLabel();
36 protected JButton findAll = new JButton();
38 protected JButton findNext = new JButton();
40 JPanel jPanel1 = new JPanel();
42 GridLayout gridLayout1 = new GridLayout();
44 protected JButton createNewGroup = new JButton();
46 JScrollPane jScrollPane1 = new JScrollPane();
48 protected JTextArea textfield = new JTextArea();
50 BorderLayout borderLayout1 = new BorderLayout();
52 JPanel jPanel2 = new JPanel();
54 JPanel jPanel3 = new JPanel();
56 JPanel jPanel4 = new JPanel();
58 BorderLayout borderLayout2 = new BorderLayout();
60 JPanel jPanel6 = new JPanel();
62 protected JCheckBox caseSensitive = new JCheckBox();
75 private void jbInit() throws Exception
77 jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
78 jLabel1.setText(MessageManager.getString("action.find"));
79 this.setLayout(borderLayout1);
80 findAll.setFont(new java.awt.Font("Verdana", 0, 12));
81 findAll.setText(MessageManager.getString("action.find_all"));
82 findAll.addActionListener(new java.awt.event.ActionListener()
84 public void actionPerformed(ActionEvent e)
86 findAll_actionPerformed(e);
89 findNext.setFont(new java.awt.Font("Verdana", 0, 12));
90 findNext.setText(MessageManager.getString("action.find_next"));
91 findNext.addActionListener(new java.awt.event.ActionListener()
93 public void actionPerformed(ActionEvent e)
95 findNext_actionPerformed(e);
98 jPanel1.setLayout(gridLayout1);
99 gridLayout1.setHgap(0);
100 gridLayout1.setRows(3);
101 gridLayout1.setVgap(2);
102 createNewGroup.setEnabled(false);
103 createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12));
104 createNewGroup.setMargin(new Insets(0, 0, 0, 0));
105 createNewGroup.setText(MessageManager.getString("label.new_feature"));
106 createNewGroup.addActionListener(new java.awt.event.ActionListener()
108 public void actionPerformed(ActionEvent e)
110 createNewGroup_actionPerformed(e);
113 textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));
114 textfield.setText("");
115 textfield.setLineWrap(true);
116 textfield.addCaretListener(new CaretListener()
118 public void caretUpdate(CaretEvent e)
120 textfield_caretUpdate(e);
123 textfield.addKeyListener(new java.awt.event.KeyAdapter()
125 public void keyPressed(KeyEvent e)
127 textfield_keyPressed(e);
131 borderLayout1.setHgap(5);
132 borderLayout1.setVgap(5);
133 jPanel4.setLayout(borderLayout2);
134 jPanel2.setPreferredSize(new Dimension(10, 1));
135 jPanel3.setPreferredSize(new Dimension(10, 1));
136 caseSensitive.setHorizontalAlignment(SwingConstants.LEFT);
137 caseSensitive.setText(MessageManager.getString("label.match_case"));
138 jPanel1.add(findNext, null);
139 jPanel1.add(findAll, null);
140 jPanel1.add(createNewGroup, null);
141 this.add(jLabel1, java.awt.BorderLayout.WEST);
142 this.add(jPanel1, java.awt.BorderLayout.EAST);
143 this.add(jPanel2, java.awt.BorderLayout.SOUTH);
144 this.add(jPanel3, java.awt.BorderLayout.NORTH);
145 this.add(jPanel4, java.awt.BorderLayout.CENTER);
146 jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);
147 jScrollPane1.getViewport().add(textfield);
148 jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);
149 jPanel4.add(caseSensitive, java.awt.BorderLayout.SOUTH);
152 protected void findNext_actionPerformed(ActionEvent e)
156 protected void findAll_actionPerformed(ActionEvent e)
160 protected void textfield_keyPressed(KeyEvent e)
162 if (e.getKeyCode() == KeyEvent.VK_ENTER)
165 findNext_actionPerformed(null);
169 public void createNewGroup_actionPerformed(ActionEvent e)
173 public void textfield_caretUpdate(CaretEvent e)
175 if (textfield.getText().indexOf(">") > -1)
177 SwingUtilities.invokeLater(new Runnable()
181 String str = textfield.getText();
185 al = new FormatAdapter().readFile(str, "Paste", "FASTA");
186 } catch (Exception ex)
189 if (al != null && al.getHeight() > 0)
191 str = jalview.analysis.AlignSeq.extractGaps(
192 jalview.util.Comparison.GapChars, al.getSequenceAt(0)
193 .getSequenceAsString());
195 textfield.setText(str);