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