| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.jbgui; |
| 22 |
|
|
| 23 |
|
import java.awt.BorderLayout; |
| 24 |
|
import java.awt.Font; |
| 25 |
|
import java.awt.GridLayout; |
| 26 |
|
import java.awt.event.ActionEvent; |
| 27 |
|
import java.awt.event.ActionListener; |
| 28 |
|
import java.awt.event.KeyAdapter; |
| 29 |
|
import java.awt.event.KeyEvent; |
| 30 |
|
|
| 31 |
|
import javax.swing.JButton; |
| 32 |
|
import javax.swing.JCheckBox; |
| 33 |
|
import javax.swing.JLabel; |
| 34 |
|
import javax.swing.JPanel; |
| 35 |
|
import javax.swing.SwingConstants; |
| 36 |
|
import javax.swing.SwingUtilities; |
| 37 |
|
import javax.swing.event.CaretEvent; |
| 38 |
|
import javax.swing.event.CaretListener; |
| 39 |
|
|
| 40 |
|
import jalview.datamodel.AlignmentI; |
| 41 |
|
import jalview.io.DataSourceType; |
| 42 |
|
import jalview.io.FileFormat; |
| 43 |
|
import jalview.io.FormatAdapter; |
| 44 |
|
import jalview.io.cache.JvCacheableInputBox; |
| 45 |
|
import jalview.util.MessageManager; |
| 46 |
|
|
| |
|
| 0% |
Uncovered Elements: 96 (96) |
Complexity: 23 |
Complexity Density: 0.32 |
|
| 47 |
|
public class GFinder extends JPanel |
| 48 |
|
{ |
| 49 |
|
private static final java.awt.Font VERDANA_12 = new Font("Verdana", |
| 50 |
|
Font.PLAIN, 12); |
| 51 |
|
|
| 52 |
|
private static final String FINDER_CACHE_KEY = "CACHE.FINDER"; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
private static final int PANEL_ROWS = 4; |
| 59 |
|
|
| 60 |
|
protected JButton createFeatures; |
| 61 |
|
|
| 62 |
|
protected JButton copyToClipboard; |
| 63 |
|
|
| 64 |
|
protected JvCacheableInputBox<String> searchBox; |
| 65 |
|
|
| 66 |
|
protected JCheckBox caseSensitive; |
| 67 |
|
|
| 68 |
|
protected JCheckBox searchDescription; |
| 69 |
|
|
| 70 |
|
protected JCheckBox searchFeatures; |
| 71 |
|
|
| 72 |
|
protected JCheckBox ignoreHidden; |
| 73 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 74 |
0 |
public GFinder()... |
| 75 |
|
{ |
| 76 |
0 |
try |
| 77 |
|
{ |
| 78 |
0 |
jbInit(); |
| 79 |
|
} catch (Exception e) |
| 80 |
|
{ |
| 81 |
0 |
e.printStackTrace(); |
| 82 |
|
} |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| |
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 1 |
Complexity Density: 0.02 |
|
| 88 |
0 |
private void jbInit() throws Exception... |
| 89 |
|
{ |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
0 |
this.setLayout(new BorderLayout()); |
| 107 |
0 |
JPanel eastPanel = new JPanel(); |
| 108 |
0 |
eastPanel.setLayout(new GridLayout(PANEL_ROWS, 1)); |
| 109 |
0 |
this.add(eastPanel, BorderLayout.EAST); |
| 110 |
0 |
JPanel centrePanel = new JPanel(); |
| 111 |
0 |
centrePanel.setLayout(new GridLayout(PANEL_ROWS, 1)); |
| 112 |
0 |
this.add(centrePanel, BorderLayout.CENTER); |
| 113 |
0 |
JPanel westPanel = new JPanel(); |
| 114 |
0 |
westPanel.setLayout(new GridLayout(PANEL_ROWS, 1)); |
| 115 |
0 |
this.add(westPanel, BorderLayout.WEST); |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
0 |
JLabel findLabel = new JLabel( |
| 121 |
|
" " + MessageManager.getString("label.find") + " "); |
| 122 |
0 |
findLabel.setFont(VERDANA_12); |
| 123 |
0 |
westPanel.add(findLabel); |
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
0 |
searchBox = new JvCacheableInputBox<>(FINDER_CACHE_KEY, 25); |
| 129 |
0 |
searchBox.getComponent().setFont(VERDANA_12); |
| 130 |
0 |
searchBox.addCaretListener(new CaretListener() |
| 131 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 132 |
0 |
@Override... |
| 133 |
|
public void caretUpdate(CaretEvent e) |
| 134 |
|
{ |
| 135 |
0 |
textfield_caretUpdate(); |
| 136 |
|
} |
| 137 |
|
}); |
| 138 |
0 |
searchBox.addKeyListener(new KeyAdapter() |
| 139 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 140 |
0 |
@Override... |
| 141 |
|
public void keyPressed(KeyEvent e) |
| 142 |
|
{ |
| 143 |
0 |
textfield_keyPressed(e); |
| 144 |
|
} |
| 145 |
|
}); |
| 146 |
0 |
centrePanel.add(searchBox.getComponent()); |
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
0 |
caseSensitive = new JCheckBox(); |
| 152 |
0 |
caseSensitive.setHorizontalAlignment(SwingConstants.LEFT); |
| 153 |
0 |
caseSensitive.setText(MessageManager.getString("label.match_case")); |
| 154 |
|
|
| 155 |
0 |
searchDescription = new JCheckBox(); |
| 156 |
0 |
searchDescription |
| 157 |
|
.setText(MessageManager.getString("label.include_description")); |
| 158 |
|
|
| 159 |
0 |
searchFeatures = new JCheckBox(); |
| 160 |
0 |
searchFeatures |
| 161 |
|
.setText(MessageManager.getString("label.include_features")); |
| 162 |
|
|
| 163 |
0 |
ignoreHidden = new JCheckBox(); |
| 164 |
0 |
ignoreHidden.setText(MessageManager.getString("label.ignore_hidden")); |
| 165 |
0 |
ignoreHidden.setToolTipText( |
| 166 |
|
MessageManager.getString("label.ignore_hidden_tooltip")); |
| 167 |
|
|
| 168 |
0 |
centrePanel.add(caseSensitive); |
| 169 |
0 |
centrePanel.add(searchDescription); |
| 170 |
0 |
centrePanel.add(searchFeatures); |
| 171 |
0 |
centrePanel.add(ignoreHidden); |
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
0 |
JButton findAll = new JButton( |
| 177 |
|
MessageManager.getString("action.find_all")); |
| 178 |
0 |
findAll.setFont(VERDANA_12); |
| 179 |
0 |
findAll.addActionListener(new ActionListener() |
| 180 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 181 |
0 |
@Override... |
| 182 |
|
public void actionPerformed(ActionEvent e) |
| 183 |
|
{ |
| 184 |
0 |
findAll_actionPerformed(); |
| 185 |
|
} |
| 186 |
|
}); |
| 187 |
0 |
JButton findNext = new JButton( |
| 188 |
|
MessageManager.getString("action.find_next")); |
| 189 |
0 |
findNext.setFont(VERDANA_12); |
| 190 |
0 |
findNext.addActionListener(new ActionListener() |
| 191 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 192 |
0 |
@Override... |
| 193 |
|
public void actionPerformed(ActionEvent e) |
| 194 |
|
{ |
| 195 |
0 |
findNext_actionPerformed(); |
| 196 |
|
} |
| 197 |
|
}); |
| 198 |
0 |
createFeatures = new JButton(); |
| 199 |
0 |
createFeatures.setEnabled(false); |
| 200 |
0 |
createFeatures.setFont(VERDANA_12); |
| 201 |
0 |
createFeatures.setText(MessageManager.getString("label.new_feature")); |
| 202 |
0 |
createFeatures.addActionListener(new ActionListener() |
| 203 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 204 |
0 |
@Override... |
| 205 |
|
public void actionPerformed(ActionEvent e) |
| 206 |
|
{ |
| 207 |
0 |
createFeatures_actionPerformed(); |
| 208 |
|
} |
| 209 |
|
}); |
| 210 |
0 |
copyToClipboard = new JButton(); |
| 211 |
0 |
copyToClipboard.setEnabled(false); |
| 212 |
0 |
copyToClipboard.setFont(VERDANA_12); |
| 213 |
0 |
copyToClipboard.setText(MessageManager.getString("label.copy")); |
| 214 |
0 |
copyToClipboard.addActionListener(new ActionListener() |
| 215 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 216 |
0 |
@Override... |
| 217 |
|
public void actionPerformed(ActionEvent e) |
| 218 |
|
{ |
| 219 |
0 |
copyToClipboard_actionPerformed(); |
| 220 |
|
} |
| 221 |
|
}); |
| 222 |
0 |
eastPanel.add(findNext); |
| 223 |
0 |
eastPanel.add(findAll); |
| 224 |
0 |
eastPanel.add(createFeatures); |
| 225 |
0 |
eastPanel.add(copyToClipboard); |
| 226 |
|
} |
| 227 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 228 |
0 |
protected void copyToClipboard_actionPerformed()... |
| 229 |
|
{ |
| 230 |
|
} |
| 231 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 232 |
0 |
protected void textfield_keyPressed(KeyEvent e)... |
| 233 |
|
{ |
| 234 |
0 |
if (e.getKeyCode() == KeyEvent.VK_ENTER) |
| 235 |
|
{ |
| 236 |
0 |
if (!searchBox.isPopupVisible()) |
| 237 |
|
{ |
| 238 |
0 |
e.consume(); |
| 239 |
0 |
findNext_actionPerformed(); |
| 240 |
|
} |
| 241 |
|
} |
| 242 |
|
} |
| 243 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 244 |
0 |
protected void findNext_actionPerformed()... |
| 245 |
|
{ |
| 246 |
|
} |
| 247 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 248 |
0 |
protected void findAll_actionPerformed()... |
| 249 |
|
{ |
| 250 |
|
} |
| 251 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 252 |
0 |
public void createFeatures_actionPerformed()... |
| 253 |
|
{ |
| 254 |
|
} |
| 255 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
| 256 |
0 |
public void textfield_caretUpdate()... |
| 257 |
|
{ |
| 258 |
|
|
| 259 |
0 |
if (false && searchBox.getUserInput().indexOf(">") > -1) |
| 260 |
|
{ |
| 261 |
0 |
SwingUtilities.invokeLater(new Runnable() |
| 262 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 263 |
0 |
@Override... |
| 264 |
|
public void run() |
| 265 |
|
{ |
| 266 |
0 |
String str = searchBox.getUserInput(); |
| 267 |
0 |
AlignmentI al = null; |
| 268 |
0 |
try |
| 269 |
|
{ |
| 270 |
0 |
al = new FormatAdapter().readFile(str, DataSourceType.PASTE, |
| 271 |
|
FileFormat.Fasta); |
| 272 |
|
} catch (Exception ex) |
| 273 |
|
{ |
| 274 |
|
} |
| 275 |
0 |
if (al != null && al.getHeight() > 0) |
| 276 |
|
{ |
| 277 |
0 |
str = jalview.analysis.AlignSeq.extractGaps( |
| 278 |
|
jalview.util.Comparison.GapChars, |
| 279 |
|
al.getSequenceAt(0).getSequenceAsString()); |
| 280 |
|
|
| 281 |
|
} |
| 282 |
|
} |
| 283 |
|
}); |
| 284 |
|
} |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
} |