1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.jbgui; |
23 |
|
|
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
import jalview.fts.api.FTSDataColumnI; |
26 |
|
import jalview.fts.core.FTSDataColumnPreferences; |
27 |
|
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; |
28 |
|
import jalview.fts.service.pdb.PDBFTSRestClient; |
29 |
|
import jalview.gui.AlignmentPanel; |
30 |
|
import jalview.gui.Desktop; |
31 |
|
import jalview.gui.JvSwingUtils; |
32 |
|
import jalview.gui.StructureViewer; |
33 |
|
import jalview.util.MessageManager; |
34 |
|
|
35 |
|
import java.awt.BorderLayout; |
36 |
|
import java.awt.CardLayout; |
37 |
|
import java.awt.Component; |
38 |
|
import java.awt.Dimension; |
39 |
|
import java.awt.FlowLayout; |
40 |
|
import java.awt.Font; |
41 |
|
import java.awt.GridLayout; |
42 |
|
import java.awt.event.ActionEvent; |
43 |
|
import java.awt.event.ItemEvent; |
44 |
|
import java.awt.event.ItemListener; |
45 |
|
import java.awt.event.KeyAdapter; |
46 |
|
import java.awt.event.KeyEvent; |
47 |
|
import java.awt.event.MouseAdapter; |
48 |
|
import java.awt.event.MouseEvent; |
49 |
|
import java.util.Arrays; |
50 |
|
import java.util.HashMap; |
51 |
|
import java.util.Map; |
52 |
|
|
53 |
|
import javax.swing.ImageIcon; |
54 |
|
import javax.swing.JButton; |
55 |
|
import javax.swing.JCheckBox; |
56 |
|
import javax.swing.JComboBox; |
57 |
|
import javax.swing.JFrame; |
58 |
|
import javax.swing.JInternalFrame; |
59 |
|
import javax.swing.JLabel; |
60 |
|
import javax.swing.JList; |
61 |
|
import javax.swing.JPanel; |
62 |
|
import javax.swing.JScrollPane; |
63 |
|
import javax.swing.JSeparator; |
64 |
|
import javax.swing.JTabbedPane; |
65 |
|
import javax.swing.JTable; |
66 |
|
import javax.swing.JTextField; |
67 |
|
import javax.swing.ListCellRenderer; |
68 |
|
import javax.swing.event.ChangeEvent; |
69 |
|
import javax.swing.event.ChangeListener; |
70 |
|
import javax.swing.event.DocumentEvent; |
71 |
|
import javax.swing.event.DocumentListener; |
72 |
|
import javax.swing.event.InternalFrameEvent; |
73 |
|
import javax.swing.table.TableColumn; |
74 |
|
|
75 |
|
import net.miginfocom.swing.MigLayout; |
76 |
|
|
77 |
|
@SuppressWarnings("serial") |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@author |
82 |
|
|
83 |
|
|
|
|
| 47.3% |
Uncovered Elements: 154 (292) |
Complexity: 66 |
Complexity Density: 0.31 |
|
84 |
|
public abstract class GStructureChooser extends JPanel |
85 |
|
implements ItemListener |
86 |
|
{ |
87 |
|
private static final Font VERDANA_12 = new Font("Verdana", 0, 12); |
88 |
|
|
89 |
|
protected static final String VIEWS_FILTER = "VIEWS_FILTER"; |
90 |
|
|
91 |
|
protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE"; |
92 |
|
|
93 |
|
protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID"; |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB"; |
99 |
|
|
100 |
|
protected JPanel statusPanel = new JPanel(); |
101 |
|
|
102 |
|
public JLabel statusBar = new JLabel(); |
103 |
|
|
104 |
|
protected String frameTitle = MessageManager |
105 |
|
.getString("label.structure_chooser"); |
106 |
|
|
107 |
|
protected JInternalFrame mainFrame = new JInternalFrame(frameTitle); |
108 |
|
|
109 |
|
protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<>(); |
110 |
|
|
111 |
|
protected AlignmentPanel ap; |
112 |
|
|
113 |
|
protected StringBuilder errorWarning = new StringBuilder(); |
114 |
|
|
115 |
|
protected JButton btn_add; |
116 |
|
|
117 |
|
protected JButton btn_newView; |
118 |
|
|
119 |
|
protected JButton btn_pdbFromFile = new JButton(); |
120 |
|
|
121 |
|
protected JCheckBox chk_superpose = new JCheckBox( |
122 |
|
MessageManager.getString("label.superpose_structures")); |
123 |
|
|
124 |
|
protected JTextField txt_search = new JTextField(14); |
125 |
|
|
126 |
|
protected JPanel pnl_switchableViews = new JPanel(new CardLayout()); |
127 |
|
|
128 |
|
protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews |
129 |
|
.getLayout()); |
130 |
|
|
131 |
|
protected JCheckBox chk_invertFilter = new JCheckBox( |
132 |
|
MessageManager.getString("label.invert")); |
133 |
|
|
134 |
|
protected ImageIcon loadingImage = new ImageIcon( |
135 |
|
getClass().getResource("/images/loading.gif")); |
136 |
|
|
137 |
|
protected ImageIcon goodImage = new ImageIcon( |
138 |
|
getClass().getResource("/images/good.png")); |
139 |
|
|
140 |
|
protected ImageIcon errorImage = new ImageIcon( |
141 |
|
getClass().getResource("/images/error.png")); |
142 |
|
|
143 |
|
protected ImageIcon warningImage = new ImageIcon( |
144 |
|
getClass().getResource("/images/warning.gif")); |
145 |
|
|
146 |
|
protected JLabel lbl_loading = new JLabel(loadingImage); |
147 |
|
|
148 |
|
protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage); |
149 |
|
|
150 |
|
protected JLabel lbl_fromFileStatus = new JLabel(errorImage); |
151 |
|
|
152 |
|
protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel(); |
153 |
|
|
154 |
|
protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel(); |
155 |
|
|
156 |
|
protected JComboBox<StructureViewer> targetView = new JComboBox<>(); |
157 |
|
|
158 |
|
protected JTable tbl_local_pdb = new JTable(); |
159 |
|
|
160 |
|
protected JTabbedPane pnl_filter = jalview.jbgui.GDesktop.createTabbedPane(); |
161 |
|
|
162 |
|
protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences( |
163 |
|
PreferenceSource.STRUCTURE_CHOOSER, |
164 |
|
PDBFTSRestClient.getInstance()); |
165 |
|
|
166 |
|
protected FTSDataColumnI[] previousWantedFields; |
167 |
|
|
168 |
|
protected static Map<String, Integer> tempUserPrefs = new HashMap<>(); |
169 |
|
|
170 |
|
private JTable tbl_summary = new JTable() |
171 |
|
{ |
172 |
|
private boolean inLayout; |
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
11 |
@Override... |
175 |
|
public boolean getScrollableTracksViewportWidth() |
176 |
|
{ |
177 |
11 |
return hasExcessWidth(); |
178 |
|
|
179 |
|
} |
180 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
181 |
2 |
@Override... |
182 |
|
public void doLayout() |
183 |
|
{ |
184 |
2 |
if (hasExcessWidth()) |
185 |
|
{ |
186 |
2 |
autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS; |
187 |
|
} |
188 |
2 |
inLayout = true; |
189 |
2 |
super.doLayout(); |
190 |
2 |
inLayout = false; |
191 |
2 |
autoResizeMode = AUTO_RESIZE_OFF; |
192 |
|
} |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
194 |
13 |
protected boolean hasExcessWidth()... |
195 |
|
{ |
196 |
13 |
return getPreferredSize().width < getParent().getWidth(); |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
199 |
0 |
@Override... |
200 |
|
public void columnMarginChanged(ChangeEvent e) |
201 |
|
{ |
202 |
0 |
if (isEditing()) |
203 |
|
{ |
204 |
0 |
removeEditor(); |
205 |
|
} |
206 |
0 |
TableColumn resizingColumn = getTableHeader().getResizingColumn(); |
207 |
|
|
208 |
|
|
209 |
0 |
if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF |
210 |
|
&& !inLayout) |
211 |
|
{ |
212 |
0 |
resizingColumn.setPreferredWidth(resizingColumn.getWidth()); |
213 |
0 |
String colHeader = resizingColumn.getHeaderValue().toString(); |
214 |
0 |
tempUserPrefs.put(colHeader, resizingColumn.getWidth()); |
215 |
|
} |
216 |
0 |
resizeAndRepaint(); |
217 |
|
} |
218 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
219 |
0 |
@Override... |
220 |
|
public String getToolTipText(MouseEvent evt) |
221 |
|
{ |
222 |
0 |
String toolTipText = null; |
223 |
0 |
java.awt.Point pnt = evt.getPoint(); |
224 |
0 |
int rowIndex = rowAtPoint(pnt); |
225 |
0 |
int colIndex = columnAtPoint(pnt); |
226 |
|
|
227 |
0 |
try |
228 |
|
{ |
229 |
0 |
if (getValueAt(rowIndex, colIndex) == null) |
230 |
|
{ |
231 |
0 |
return null; |
232 |
|
} |
233 |
0 |
toolTipText = getValueAt(rowIndex, colIndex).toString(); |
234 |
|
} catch (Exception e) |
235 |
|
{ |
236 |
|
|
237 |
|
} |
238 |
0 |
toolTipText = (toolTipText == null ? null |
239 |
0 |
: (toolTipText.length() > 500 |
240 |
|
? JvSwingUtils.wrapTooltip(true, |
241 |
|
"\"" + toolTipText.subSequence(0, 500) |
242 |
|
+ "...\"") |
243 |
|
: JvSwingUtils.wrapTooltip(true, toolTipText))); |
244 |
0 |
return toolTipText; |
245 |
|
} |
246 |
|
}; |
247 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
248 |
1 |
public GStructureChooser()... |
249 |
|
{ |
250 |
1 |
try |
251 |
|
{ |
252 |
1 |
jbInit(); |
253 |
1 |
mainFrame.setVisible(false); |
254 |
1 |
mainFrame.invalidate(); |
255 |
1 |
mainFrame.pack(); |
256 |
|
} catch (Exception e) |
257 |
|
{ |
258 |
0 |
System.out.println(e); |
259 |
0 |
e.printStackTrace(); |
260 |
|
} |
261 |
|
} |
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
@throws |
267 |
|
|
|
|
| 96% |
Uncovered Elements: 4 (101) |
Complexity: 5 |
Complexity Density: 0.05 |
|
268 |
1 |
private void jbInit() throws Exception... |
269 |
|
{ |
270 |
1 |
Integer width = tempUserPrefs.get("structureChooser.width") == null |
271 |
|
? 800 |
272 |
|
: tempUserPrefs.get("structureChooser.width"); |
273 |
1 |
Integer height = tempUserPrefs.get("structureChooser.height") == null |
274 |
|
? 400 |
275 |
|
: tempUserPrefs.get("structureChooser.height"); |
276 |
1 |
tbl_summary.setAutoCreateRowSorter(true); |
277 |
1 |
tbl_summary.getTableHeader().setReorderingAllowed(false); |
278 |
1 |
tbl_summary.addMouseListener(new MouseAdapter() |
279 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
280 |
0 |
@Override... |
281 |
|
public void mouseClicked(MouseEvent e) |
282 |
|
{ |
283 |
0 |
validateSelections(); |
284 |
|
} |
285 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
286 |
0 |
@Override... |
287 |
|
public void mouseReleased(MouseEvent e) |
288 |
|
{ |
289 |
0 |
validateSelections(); |
290 |
|
} |
291 |
|
}); |
292 |
1 |
tbl_summary.addKeyListener(new KeyAdapter() |
293 |
|
{ |
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.35 |
|
294 |
0 |
@Override... |
295 |
|
public void keyPressed(KeyEvent evt) |
296 |
|
{ |
297 |
0 |
validateSelections(); |
298 |
0 |
switch (evt.getKeyCode()) |
299 |
|
{ |
300 |
0 |
case KeyEvent.VK_ESCAPE: |
301 |
0 |
mainFrame.dispose(); |
302 |
0 |
break; |
303 |
0 |
case KeyEvent.VK_ENTER: |
304 |
0 |
if (btn_add.isEnabled()) |
305 |
|
{ |
306 |
0 |
add_ActionPerformed(); |
307 |
|
} |
308 |
0 |
break; |
309 |
0 |
case KeyEvent.VK_TAB: |
310 |
0 |
if (evt.isShiftDown()) |
311 |
|
{ |
312 |
0 |
pnl_filter.requestFocus(); |
313 |
|
} |
314 |
|
else |
315 |
|
{ |
316 |
0 |
btn_add.requestFocus(); |
317 |
|
} |
318 |
0 |
evt.consume(); |
319 |
0 |
break; |
320 |
0 |
default: |
321 |
0 |
return; |
322 |
|
} |
323 |
|
} |
324 |
|
}); |
325 |
|
|
326 |
1 |
JButton btn_cancel = new JButton( |
327 |
|
MessageManager.getString("action.cancel")); |
328 |
1 |
btn_cancel.setFont(VERDANA_12); |
329 |
1 |
btn_cancel.addActionListener(new java.awt.event.ActionListener() |
330 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
331 |
0 |
@Override... |
332 |
|
public void actionPerformed(ActionEvent e) |
333 |
|
{ |
334 |
0 |
closeAction(pnl_filter.getHeight()); |
335 |
|
} |
336 |
|
}); |
337 |
1 |
btn_cancel.addKeyListener(new KeyAdapter() |
338 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
339 |
0 |
@Override... |
340 |
|
public void keyPressed(KeyEvent evt) |
341 |
|
{ |
342 |
0 |
if (evt.getKeyCode() == KeyEvent.VK_ENTER) |
343 |
|
{ |
344 |
0 |
closeAction(pnl_filter.getHeight()); |
345 |
|
} |
346 |
|
} |
347 |
|
}); |
348 |
|
|
349 |
1 |
tbl_local_pdb.setAutoCreateRowSorter(true); |
350 |
1 |
tbl_local_pdb.getTableHeader().setReorderingAllowed(false); |
351 |
1 |
tbl_local_pdb.addMouseListener(new MouseAdapter() |
352 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
353 |
0 |
@Override... |
354 |
|
public void mouseClicked(MouseEvent e) |
355 |
|
{ |
356 |
0 |
validateSelections(); |
357 |
|
} |
358 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
359 |
0 |
@Override... |
360 |
|
public void mouseReleased(MouseEvent e) |
361 |
|
{ |
362 |
0 |
validateSelections(); |
363 |
|
} |
364 |
|
}); |
365 |
1 |
tbl_local_pdb.addKeyListener(new KeyAdapter() |
366 |
|
{ |
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 7 |
Complexity Density: 0.37 |
|
367 |
0 |
@Override... |
368 |
|
public void keyPressed(KeyEvent evt) |
369 |
|
{ |
370 |
0 |
validateSelections(); |
371 |
0 |
switch (evt.getKeyCode()) |
372 |
|
{ |
373 |
0 |
case KeyEvent.VK_ESCAPE: |
374 |
0 |
mainFrame.dispose(); |
375 |
0 |
break; |
376 |
0 |
case KeyEvent.VK_ENTER: |
377 |
0 |
if (btn_add.isEnabled()) |
378 |
|
{ |
379 |
0 |
add_ActionPerformed(); |
380 |
|
} |
381 |
0 |
break; |
382 |
0 |
case KeyEvent.VK_TAB: |
383 |
0 |
if (evt.isShiftDown()) |
384 |
|
{ |
385 |
0 |
cmb_filterOption.requestFocus(); |
386 |
|
} |
387 |
|
else |
388 |
|
{ |
389 |
0 |
if (btn_add.isEnabled()) |
390 |
|
{ |
391 |
0 |
btn_add.requestFocus(); |
392 |
|
} |
393 |
|
else |
394 |
|
{ |
395 |
0 |
btn_cancel.requestFocus(); |
396 |
|
} |
397 |
|
} |
398 |
0 |
evt.consume(); |
399 |
0 |
break; |
400 |
0 |
default: |
401 |
0 |
return; |
402 |
|
} |
403 |
|
} |
404 |
|
}); |
405 |
|
|
406 |
1 |
btn_newView = new JButton(MessageManager.getString("action.new_view")); |
407 |
1 |
btn_newView.setFont(VERDANA_12); |
408 |
1 |
btn_newView.addActionListener(new java.awt.event.ActionListener() |
409 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
410 |
0 |
@Override... |
411 |
|
public void actionPerformed(ActionEvent e) |
412 |
|
{ |
413 |
0 |
newView_ActionPerformed(); |
414 |
|
} |
415 |
|
}); |
416 |
1 |
btn_newView.addKeyListener(new KeyAdapter() |
417 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
418 |
0 |
@Override... |
419 |
|
public void keyPressed(KeyEvent evt) |
420 |
|
{ |
421 |
0 |
if (evt.getKeyCode() == KeyEvent.VK_ENTER) |
422 |
|
{ |
423 |
0 |
newView_ActionPerformed(); |
424 |
|
} |
425 |
|
} |
426 |
|
}); |
427 |
|
|
428 |
1 |
btn_add = new JButton(MessageManager.getString("action.add")); |
429 |
1 |
btn_add.setFont(VERDANA_12); |
430 |
1 |
btn_add.addActionListener(new java.awt.event.ActionListener() |
431 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
432 |
0 |
@Override... |
433 |
|
public void actionPerformed(ActionEvent e) |
434 |
|
{ |
435 |
0 |
add_ActionPerformed(); |
436 |
|
} |
437 |
|
}); |
438 |
1 |
btn_add.addKeyListener(new KeyAdapter() |
439 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
440 |
0 |
@Override... |
441 |
|
public void keyPressed(KeyEvent evt) |
442 |
|
{ |
443 |
0 |
if (evt.getKeyCode() == KeyEvent.VK_ENTER) |
444 |
|
{ |
445 |
0 |
add_ActionPerformed(); |
446 |
|
} |
447 |
|
} |
448 |
|
}); |
449 |
|
|
450 |
1 |
btn_pdbFromFile.setFont(VERDANA_12); |
451 |
1 |
String btn_title = MessageManager.getString("label.select_pdb_file"); |
452 |
1 |
btn_pdbFromFile.setText(btn_title + " "); |
453 |
1 |
btn_pdbFromFile.addActionListener(new java.awt.event.ActionListener() |
454 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
455 |
0 |
@Override... |
456 |
|
public void actionPerformed(ActionEvent e) |
457 |
|
{ |
458 |
0 |
pdbFromFile_actionPerformed(); |
459 |
|
} |
460 |
|
}); |
461 |
1 |
btn_pdbFromFile.addKeyListener(new KeyAdapter() |
462 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
463 |
0 |
@Override... |
464 |
|
public void keyPressed(KeyEvent evt) |
465 |
|
{ |
466 |
0 |
if (evt.getKeyCode() == KeyEvent.VK_ENTER) |
467 |
|
{ |
468 |
0 |
pdbFromFile_actionPerformed(); |
469 |
|
} |
470 |
|
} |
471 |
|
}); |
472 |
|
|
473 |
1 |
JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary); |
474 |
1 |
scrl_foundStructures.setPreferredSize(new Dimension(width, height)); |
475 |
|
|
476 |
1 |
JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb); |
477 |
1 |
scrl_localPDB.setPreferredSize(new Dimension(width, height)); |
478 |
1 |
scrl_localPDB.setHorizontalScrollBarPolicy( |
479 |
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
480 |
|
|
481 |
1 |
chk_invertFilter.setFont(VERDANA_12); |
482 |
1 |
txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true, |
483 |
|
MessageManager.getString("label.enter_pdb_id_tip"))); |
484 |
1 |
txt_search.getDocument().addDocumentListener(new DocumentListener() |
485 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
486 |
0 |
@Override... |
487 |
|
public void insertUpdate(DocumentEvent e) |
488 |
|
{ |
489 |
0 |
txt_search_ActionPerformed(); |
490 |
|
} |
491 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
492 |
0 |
@Override... |
493 |
|
public void removeUpdate(DocumentEvent e) |
494 |
|
{ |
495 |
0 |
txt_search_ActionPerformed(); |
496 |
|
} |
497 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
498 |
0 |
@Override... |
499 |
|
public void changedUpdate(DocumentEvent e) |
500 |
|
{ |
501 |
0 |
txt_search_ActionPerformed(); |
502 |
|
} |
503 |
|
}); |
504 |
|
|
505 |
1 |
cmb_filterOption.setFont(VERDANA_12); |
506 |
1 |
cmb_filterOption.setToolTipText( |
507 |
|
MessageManager.getString("info.select_filter_option")); |
508 |
1 |
cmb_filterOption.addItemListener(this); |
509 |
|
|
510 |
1 |
cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer( |
511 |
|
(ListCellRenderer<Object>) cmb_filterOption.getRenderer()) |
512 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
513 |
16 |
@Override... |
514 |
|
protected boolean addSeparatorAfter(JList list, FilterOption value, |
515 |
|
int index) |
516 |
|
{ |
517 |
16 |
return value.isAddSeparatorAfter(); |
518 |
|
} |
519 |
|
}); |
520 |
|
|
521 |
1 |
chk_invertFilter.addItemListener(this); |
522 |
|
|
523 |
1 |
targetView.setVisible(false); |
524 |
|
|
525 |
1 |
JPanel actionsPanel = new JPanel(new MigLayout()); |
526 |
1 |
actionsPanel.add(targetView, "left"); |
527 |
1 |
actionsPanel.add(btn_add, "wrap"); |
528 |
1 |
actionsPanel.add(chk_superpose, "left"); |
529 |
1 |
actionsPanel.add(btn_newView); |
530 |
1 |
actionsPanel.add(btn_cancel, "right"); |
531 |
|
|
532 |
1 |
JPanel pnl_main = new JPanel(); |
533 |
1 |
pnl_main.add(cmb_filterOption); |
534 |
1 |
pnl_main.add(lbl_loading); |
535 |
1 |
pnl_main.add(chk_invertFilter); |
536 |
1 |
lbl_loading.setVisible(false); |
537 |
|
|
538 |
1 |
JPanel pnl_fileChooser = new JPanel(new FlowLayout()); |
539 |
1 |
pnl_fileChooser.add(btn_pdbFromFile); |
540 |
1 |
pnl_fileChooser.add(lbl_fromFileStatus); |
541 |
1 |
JPanel pnl_fileChooserBL = new JPanel(new BorderLayout()); |
542 |
1 |
pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.NORTH); |
543 |
1 |
pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER); |
544 |
|
|
545 |
1 |
JPanel pnl_idInput = new JPanel(new FlowLayout()); |
546 |
1 |
pnl_idInput.add(txt_search); |
547 |
1 |
pnl_idInput.add(lbl_pdbManualFetchStatus); |
548 |
|
|
549 |
1 |
JPanel pnl_idInputBL = new JPanel(new BorderLayout()); |
550 |
1 |
pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH); |
551 |
1 |
pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER); |
552 |
|
|
553 |
1 |
final String foundStructureSummary = MessageManager |
554 |
|
.getString("label.found_structures_summary"); |
555 |
1 |
final String configureCols = MessageManager |
556 |
|
.getString("label.configure_displayed_columns"); |
557 |
1 |
ChangeListener changeListener = new ChangeListener() |
558 |
|
{ |
|
|
| 56.5% |
Uncovered Elements: 10 (23) |
Complexity: 4 |
Complexity Density: 0.24 |
|
559 |
1 |
@Override... |
560 |
|
public void stateChanged(ChangeEvent changeEvent) |
561 |
|
{ |
562 |
1 |
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent |
563 |
|
.getSource(); |
564 |
1 |
int index = sourceTabbedPane.getSelectedIndex(); |
565 |
1 |
btn_add.setVisible(targetView.isVisible()); |
566 |
1 |
btn_newView.setVisible(true); |
567 |
1 |
btn_cancel.setVisible(true); |
568 |
1 |
if (sourceTabbedPane.getTitleAt(index).equals(configureCols)) |
569 |
|
{ |
570 |
0 |
btn_add.setEnabled(false); |
571 |
0 |
btn_cancel.setEnabled(false); |
572 |
0 |
btn_add.setVisible(false); |
573 |
0 |
btn_newView.setEnabled(false); |
574 |
0 |
btn_cancel.setVisible(false); |
575 |
0 |
previousWantedFields = pdbDocFieldPrefs |
576 |
|
.getStructureSummaryFields() |
577 |
|
.toArray(new FTSDataColumnI[0]); |
578 |
|
} |
579 |
1 |
if (sourceTabbedPane.getTitleAt(index) |
580 |
|
.equals(foundStructureSummary)) |
581 |
|
{ |
582 |
1 |
btn_cancel.setEnabled(true); |
583 |
1 |
if (wantedFieldsUpdated()) |
584 |
|
{ |
585 |
1 |
tabRefresh(); |
586 |
|
} |
587 |
|
else |
588 |
|
{ |
589 |
0 |
validateSelections(); |
590 |
|
} |
591 |
|
} |
592 |
|
} |
593 |
|
}; |
594 |
1 |
pnl_filter.addChangeListener(changeListener); |
595 |
1 |
pnl_filter.setPreferredSize(new Dimension(width, height)); |
596 |
1 |
pnl_filter.add(foundStructureSummary, scrl_foundStructures); |
597 |
1 |
pnl_filter.add(configureCols, pdbDocFieldPrefs); |
598 |
|
|
599 |
1 |
JPanel pnl_locPDB = new JPanel(new BorderLayout()); |
600 |
1 |
pnl_locPDB.add(scrl_localPDB); |
601 |
|
|
602 |
1 |
pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE); |
603 |
1 |
pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID); |
604 |
1 |
pnl_switchableViews.add(pnl_filter, VIEWS_FILTER); |
605 |
1 |
pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB); |
606 |
|
|
607 |
1 |
this.setLayout(new BorderLayout()); |
608 |
1 |
this.add(pnl_main, java.awt.BorderLayout.NORTH); |
609 |
1 |
this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER); |
610 |
|
|
611 |
1 |
statusPanel.setLayout(new GridLayout()); |
612 |
|
|
613 |
1 |
JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout()); |
614 |
1 |
pnl_actionsAndStatus.add(actionsPanel, BorderLayout.CENTER); |
615 |
1 |
pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH); |
616 |
1 |
statusPanel.add(statusBar, null); |
617 |
1 |
this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH); |
618 |
|
|
619 |
1 |
mainFrame.addInternalFrameListener( |
620 |
|
new javax.swing.event.InternalFrameAdapter() |
621 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
622 |
0 |
@Override... |
623 |
|
public void internalFrameClosing(InternalFrameEvent e) |
624 |
|
{ |
625 |
0 |
closeAction(pnl_filter.getHeight()); |
626 |
|
} |
627 |
|
}); |
628 |
1 |
mainFrame.setVisible(true); |
629 |
1 |
mainFrame.setContentPane(this); |
630 |
1 |
mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
631 |
1 |
Integer x = tempUserPrefs.get("structureChooser.x"); |
632 |
1 |
Integer y = tempUserPrefs.get("structureChooser.y"); |
633 |
1 |
if (x != null && y != null) |
634 |
|
{ |
635 |
0 |
mainFrame.setLocation(x, y); |
636 |
|
} |
637 |
1 |
Desktop.addInternalFrame(mainFrame, frameTitle, width, height); |
638 |
|
} |
639 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
640 |
0 |
protected void closeAction(int preferredHeight)... |
641 |
|
{ |
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
647 |
0 |
tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth()); |
648 |
0 |
tempUserPrefs.put("structureChooser.height", preferredHeight); |
649 |
0 |
tempUserPrefs.put("structureChooser.x", mainFrame.getX()); |
650 |
0 |
tempUserPrefs.put("structureChooser.y", mainFrame.getY()); |
651 |
0 |
mainFrame.dispose(); |
652 |
|
} |
653 |
|
|
|
|
| 37.5% |
Uncovered Elements: 5 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
654 |
1 |
public boolean wantedFieldsUpdated()... |
655 |
|
{ |
656 |
1 |
if (previousWantedFields == null) |
657 |
|
{ |
658 |
1 |
return true; |
659 |
|
} |
660 |
|
|
661 |
0 |
FTSDataColumnI[] currentWantedFields = pdbDocFieldPrefs |
662 |
|
.getStructureSummaryFields().toArray(new FTSDataColumnI[0]); |
663 |
0 |
return Arrays.equals(currentWantedFields, previousWantedFields) ? false |
664 |
|
: true; |
665 |
|
|
666 |
|
} |
667 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
668 |
0 |
@Override... |
669 |
|
|
670 |
|
|
671 |
|
|
672 |
|
public void itemStateChanged(ItemEvent e) |
673 |
|
{ |
674 |
0 |
stateChanged(e); |
675 |
|
} |
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
@author |
681 |
|
|
682 |
|
|
|
|
| 56.5% |
Uncovered Elements: 10 (23) |
Complexity: 10 |
Complexity Density: 0.77 |
|
683 |
|
public class FilterOption |
684 |
|
{ |
685 |
|
private String name; |
686 |
|
|
687 |
|
private String value; |
688 |
|
|
689 |
|
private String view; |
690 |
|
|
691 |
|
private boolean addSeparatorAfter; |
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
|
696 |
|
@param |
697 |
|
|
698 |
|
@param |
699 |
|
|
700 |
|
@param |
701 |
|
|
702 |
|
@param |
703 |
|
|
704 |
|
|
705 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
706 |
26 |
public FilterOption(String name, String value, String view,... |
707 |
|
boolean addSeparatorAfter) |
708 |
|
{ |
709 |
26 |
this.name = name; |
710 |
26 |
this.value = value; |
711 |
26 |
this.view = view; |
712 |
26 |
this.addSeparatorAfter = addSeparatorAfter; |
713 |
|
} |
714 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
715 |
1 |
public String getName()... |
716 |
|
{ |
717 |
1 |
return name; |
718 |
|
} |
719 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
720 |
0 |
public void setName(String name)... |
721 |
|
{ |
722 |
0 |
this.name = name; |
723 |
|
} |
724 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
725 |
1 |
public String getValue()... |
726 |
|
{ |
727 |
1 |
return value; |
728 |
|
} |
729 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
730 |
0 |
public void setValue(String value)... |
731 |
|
{ |
732 |
0 |
this.value = value; |
733 |
|
} |
734 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
735 |
0 |
public String getView()... |
736 |
|
{ |
737 |
0 |
return view; |
738 |
|
} |
739 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
740 |
0 |
public void setView(String view)... |
741 |
|
{ |
742 |
0 |
this.view = view; |
743 |
|
} |
744 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
745 |
22 |
@Override... |
746 |
|
public String toString() |
747 |
|
{ |
748 |
22 |
return this.name; |
749 |
|
} |
750 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
751 |
16 |
public boolean isAddSeparatorAfter()... |
752 |
|
{ |
753 |
16 |
return addSeparatorAfter; |
754 |
|
} |
755 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
756 |
0 |
public void setAddSeparatorAfter(boolean addSeparatorAfter)... |
757 |
|
{ |
758 |
0 |
this.addSeparatorAfter = addSeparatorAfter; |
759 |
|
} |
760 |
|
} |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
765 |
|
|
766 |
|
@author |
767 |
|
|
768 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 8 |
Complexity Density: 0.89 |
|
769 |
|
public class AssociateSeqOptions |
770 |
|
{ |
771 |
|
private SequenceI sequence; |
772 |
|
|
773 |
|
private String name; |
774 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
775 |
0 |
public AssociateSeqOptions(SequenceI seq)... |
776 |
|
{ |
777 |
0 |
this.sequence = seq; |
778 |
0 |
this.name = (seq.getName().length() >= 23) |
779 |
|
? seq.getName().substring(0, 23) |
780 |
|
: seq.getName(); |
781 |
|
} |
782 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
783 |
0 |
public AssociateSeqOptions(String name, SequenceI seq)... |
784 |
|
{ |
785 |
0 |
this.name = name; |
786 |
0 |
this.sequence = seq; |
787 |
|
} |
788 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
789 |
0 |
@Override... |
790 |
|
public String toString() |
791 |
|
{ |
792 |
0 |
return name; |
793 |
|
} |
794 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
795 |
0 |
public String getName()... |
796 |
|
{ |
797 |
0 |
return name; |
798 |
|
} |
799 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
800 |
0 |
public void setName(String name)... |
801 |
|
{ |
802 |
0 |
this.name = name; |
803 |
|
} |
804 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
805 |
0 |
public SequenceI getSequence()... |
806 |
|
{ |
807 |
0 |
return sequence; |
808 |
|
} |
809 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
810 |
0 |
public void setSequence(SequenceI sequence)... |
811 |
|
{ |
812 |
0 |
this.sequence = sequence; |
813 |
|
} |
814 |
|
|
815 |
|
} |
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
@author |
823 |
|
|
824 |
|
|
|
|
| 35.3% |
Uncovered Elements: 11 (17) |
Complexity: 6 |
Complexity Density: 0.6 |
|
825 |
|
public class AssociateSeqPanel extends JPanel implements ItemListener |
826 |
|
{ |
827 |
|
private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<>(); |
828 |
|
|
829 |
|
private JLabel lbl_associateSeq = new JLabel(); |
830 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
831 |
2 |
public AssociateSeqPanel()... |
832 |
|
{ |
833 |
2 |
this.setLayout(new FlowLayout()); |
834 |
2 |
this.add(cmb_assSeq); |
835 |
2 |
this.add(lbl_associateSeq); |
836 |
2 |
cmb_assSeq.setToolTipText( |
837 |
|
MessageManager.getString("info.associate_wit_sequence")); |
838 |
2 |
cmb_assSeq.addItemListener(this); |
839 |
|
} |
840 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
841 |
0 |
public void loadCmbAssSeq()... |
842 |
|
{ |
843 |
0 |
populateCmbAssociateSeqOptions(cmb_assSeq, lbl_associateSeq); |
844 |
|
} |
845 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
846 |
0 |
public JComboBox<AssociateSeqOptions> getCmb_assSeq()... |
847 |
|
{ |
848 |
0 |
return cmb_assSeq; |
849 |
|
} |
850 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
851 |
0 |
public void setCmb_assSeq(JComboBox<AssociateSeqOptions> cmb_assSeq)... |
852 |
|
{ |
853 |
0 |
this.cmb_assSeq = cmb_assSeq; |
854 |
|
} |
855 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
856 |
0 |
@Override... |
857 |
|
public void itemStateChanged(ItemEvent e) |
858 |
|
{ |
859 |
0 |
if (e.getStateChange() == ItemEvent.SELECTED) |
860 |
|
{ |
861 |
0 |
cmbAssSeqStateChanged(); |
862 |
|
} |
863 |
|
} |
864 |
|
} |
865 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
866 |
0 |
public JTable getResultTable()... |
867 |
|
{ |
868 |
0 |
return tbl_summary; |
869 |
|
} |
870 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
871 |
4 |
public JComboBox<FilterOption> getCmbFilterOption()... |
872 |
|
{ |
873 |
4 |
return cmb_filterOption; |
874 |
|
} |
875 |
|
|
876 |
|
|
877 |
|
|
878 |
|
|
879 |
|
|
880 |
|
@author |
881 |
|
|
882 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
883 |
|
public abstract class CustomComboSeparatorsRenderer |
884 |
|
implements ListCellRenderer<Object> |
885 |
|
{ |
886 |
|
private ListCellRenderer<Object> regent; |
887 |
|
|
888 |
|
private JPanel separatorPanel = new JPanel(new BorderLayout()); |
889 |
|
|
890 |
|
private JSeparator jSeparator = new JSeparator(); |
891 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
892 |
1 |
public CustomComboSeparatorsRenderer(... |
893 |
|
ListCellRenderer<Object> listCellRenderer) |
894 |
|
{ |
895 |
1 |
this.regent = listCellRenderer; |
896 |
|
} |
897 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
898 |
25 |
@Override... |
899 |
|
public Component getListCellRendererComponent(JList list, Object value, |
900 |
|
int index, boolean isSelected, boolean cellHasFocus) |
901 |
|
{ |
902 |
|
|
903 |
25 |
Component comp = regent.getListCellRendererComponent(list, value, |
904 |
|
index, isSelected, cellHasFocus); |
905 |
25 |
if (index != -1 |
906 |
|
&& addSeparatorAfter(list, (FilterOption) value, index)) |
907 |
|
{ |
908 |
1 |
separatorPanel.removeAll(); |
909 |
1 |
separatorPanel.add(comp, BorderLayout.CENTER); |
910 |
1 |
separatorPanel.add(jSeparator, BorderLayout.SOUTH); |
911 |
1 |
return separatorPanel; |
912 |
|
} |
913 |
|
else |
914 |
|
{ |
915 |
24 |
return comp; |
916 |
|
} |
917 |
|
} |
918 |
|
|
919 |
|
protected abstract boolean addSeparatorAfter(JList list, |
920 |
|
FilterOption value, int index); |
921 |
|
} |
922 |
|
|
923 |
|
protected abstract void stateChanged(ItemEvent e); |
924 |
|
|
925 |
|
protected abstract void add_ActionPerformed(); |
926 |
|
|
927 |
|
protected abstract void newView_ActionPerformed(); |
928 |
|
|
929 |
|
protected abstract void pdbFromFile_actionPerformed(); |
930 |
|
|
931 |
|
protected abstract void txt_search_ActionPerformed(); |
932 |
|
|
933 |
|
protected abstract void populateCmbAssociateSeqOptions( |
934 |
|
JComboBox<AssociateSeqOptions> cmb_assSeq, |
935 |
|
JLabel lbl_associateSeq); |
936 |
|
|
937 |
|
protected abstract void cmbAssSeqStateChanged(); |
938 |
|
|
939 |
|
protected abstract void tabRefresh(); |
940 |
|
|
941 |
|
protected abstract void validateSelections(); |
942 |
|
} |