2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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.
22 package jalview.jbgui;
24 import java.awt.BorderLayout;
25 import java.awt.CardLayout;
26 import java.awt.Component;
27 import java.awt.Dimension;
28 import java.awt.FlowLayout;
30 import java.awt.GridBagConstraints;
31 import java.awt.GridBagLayout;
32 import java.awt.GridLayout;
33 import java.awt.Insets;
34 import java.awt.Point;
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
37 import java.awt.event.ItemEvent;
38 import java.awt.event.ItemListener;
39 import java.awt.event.KeyAdapter;
40 import java.awt.event.KeyEvent;
41 import java.awt.event.MouseAdapter;
42 import java.awt.event.MouseEvent;
43 import java.util.Arrays;
44 import java.util.HashMap;
47 import javax.swing.ImageIcon;
48 import javax.swing.JButton;
49 import javax.swing.JCheckBox;
50 import javax.swing.JComboBox;
51 import javax.swing.JFrame;
52 import javax.swing.JInternalFrame;
53 import javax.swing.JLabel;
54 import javax.swing.JList;
55 import javax.swing.JPanel;
56 import javax.swing.JScrollPane;
57 import javax.swing.JSeparator;
58 import javax.swing.JTabbedPane;
59 import javax.swing.JTable;
60 import javax.swing.JTextField;
61 import javax.swing.ListCellRenderer;
62 import javax.swing.SwingConstants;
63 import javax.swing.Timer;
64 import javax.swing.event.ChangeEvent;
65 import javax.swing.event.ChangeListener;
66 import javax.swing.event.DocumentEvent;
67 import javax.swing.event.DocumentListener;
68 import javax.swing.event.InternalFrameEvent;
69 import javax.swing.table.TableColumn;
71 import jalview.datamodel.SequenceI;
72 import jalview.fts.api.FTSDataColumnI;
73 import jalview.fts.core.FTSDataColumnPreferences;
74 import jalview.gui.AlignmentPanel;
75 import jalview.gui.Desktop;
76 import jalview.gui.JvSwingUtils;
77 import jalview.gui.StructureViewer;
78 import jalview.structure.StructureImportSettings;
79 import jalview.structure.StructureImportSettings.TFType;
80 import jalview.util.MessageManager;
81 import jalview.util.Platform;
82 import net.miginfocom.swing.MigLayout;
84 @SuppressWarnings("serial")
86 * GUI layout for structure chooser
91 public abstract class GStructureChooser extends JPanel
92 implements ItemListener
94 private static final Font VERDANA_12 = new Font("Verdana", 0, 12);
96 private static final Font VERDANA_10 = new Font("Verdana", 0, 10);
98 public static final String VIEWS_FILTER = "VIEWS_FILTER";
100 protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE";
102 protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
105 * 'cached' structure view
107 protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB";
109 protected JPanel statusPanel = new JPanel();
111 public JLabel statusBar = new JLabel();
113 protected String frameTitle = MessageManager
114 .getString("label.structure_chooser");
116 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
118 protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<>();
120 protected AlignmentPanel ap;
122 protected StringBuilder errorWarning = new StringBuilder();
124 protected JButton btn_add;
126 protected JButton btn_newView;
128 protected JButton btn_pdbFromFile = new JButton();
130 protected JLabel lbl_pdbFile = new JLabel();
132 protected JLabel lbl_chooseTempFacType = new JLabel();
134 protected JComboBox<StructureImportSettings.TFType> combo_tempFacAs = new JComboBox<>();
136 protected boolean tempFacAsChanged = false;
138 protected JButton btn_paeMatrixFile = new JButton();
140 protected JLabel lbl_paeFile = new JLabel();
142 // holder for icon and button
143 protected JPanel pnl_queryTDB;
145 protected JButton btn_queryTDB = new JButton();
147 protected JCheckBox chk_superpose = new JCheckBox(
148 MessageManager.getString("label.superpose_structures"));
150 protected JTextField txt_search = new JTextField(14);
152 protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
154 protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews
157 protected JCheckBox chk_invertFilter = new JCheckBox(
158 MessageManager.getString("label.invert"));
160 protected ImageIcon loadingImage = new ImageIcon(
161 getClass().getResource("/images/loading.gif"));
163 protected ImageIcon goodImage = new ImageIcon(
164 getClass().getResource("/images/good.png"));
166 protected ImageIcon errorImage = new ImageIcon(
167 getClass().getResource("/images/error.png"));
169 protected ImageIcon warningImage = new ImageIcon(
170 getClass().getResource("/images/warning.gif"));
172 protected ImageIcon tdbImage = new ImageIcon(getClass()
173 .getResource("/images/3d-beacons-logo-transparent.png"));
175 protected JLabel lbl_loading = new JLabel(loadingImage);
177 protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
179 // protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
181 protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel();
183 protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel();
185 protected JComboBox<StructureViewer> targetView = new JComboBox<>();
187 protected JTable tbl_local_pdb = new JTable();
189 protected JTabbedPane pnl_filter = new JTabbedPane();
191 protected abstract FTSDataColumnPreferences getFTSDocFieldPrefs();
193 protected abstract void setFTSDocFieldPrefs(
194 FTSDataColumnPreferences newPrefs);
196 protected FTSDataColumnI[] previousWantedFields;
198 protected static Map<String, Integer> tempUserPrefs = new HashMap<>();
200 private JTable tbl_summary = new JTable()
202 private boolean inLayout;
205 public boolean getScrollableTracksViewportWidth()
207 return hasExcessWidth();
212 public void doLayout()
214 if (hasExcessWidth())
216 autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS;
221 autoResizeMode = AUTO_RESIZE_OFF;
224 protected boolean hasExcessWidth()
226 return getPreferredSize().width < getParent().getWidth();
230 public void columnMarginChanged(ChangeEvent e)
236 TableColumn resizingColumn = getTableHeader().getResizingColumn();
237 // Need to do this here, before the parent's
238 // layout manager calls getPreferredSize().
239 if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF
242 resizingColumn.setPreferredWidth(resizingColumn.getWidth());
243 String colHeader = resizingColumn.getHeaderValue().toString();
244 tempUserPrefs.put(colHeader, resizingColumn.getWidth());
250 public String getToolTipText(MouseEvent evt)
252 String toolTipText = null;
253 java.awt.Point pnt = evt.getPoint();
254 int rowIndex = rowAtPoint(pnt);
255 int colIndex = columnAtPoint(pnt);
259 if (getValueAt(rowIndex, colIndex) == null)
263 toolTipText = getValueAt(rowIndex, colIndex).toString();
264 } catch (Exception e)
266 // e.printStackTrace();
268 toolTipText = (toolTipText == null ? null
269 : (toolTipText.length() > 500
270 ? JvSwingUtils.wrapTooltip(true,
271 "\"" + toolTipText.subSequence(0, 500)
273 : JvSwingUtils.wrapTooltip(true, toolTipText)));
278 public GStructureChooser()
282 protected void initDialog()
288 mainFrame.setFrameIcon(null);
289 mainFrame.setVisible(false);
290 mainFrame.invalidate();
292 } catch (Exception e)
294 System.out.println(e); // for JavaScript TypeError
299 // BH SwingJS optimization
300 // (a) 100-ms interruptable timer for text entry -- BH 1/10/2019
301 // (b) two-character minimum, at least for JavaScript.
305 protected void txt_search_ActionPerformedDelayed()
311 timer = new Timer(300, new ActionListener()
315 public void actionPerformed(ActionEvent e)
317 txt_search_ActionPerformed();
320 timer.setRepeats(false);
326 * Initializes the GUI default properties
330 private void jbInit() throws Exception
332 Integer width = tempUserPrefs.get("structureChooser.width") == null
334 : tempUserPrefs.get("structureChooser.width");
335 Integer height = tempUserPrefs.get("structureChooser.height") == null
337 : tempUserPrefs.get("structureChooser.height");
338 tbl_summary.setAutoCreateRowSorter(true);
339 tbl_summary.getTableHeader().setReorderingAllowed(false);
340 tbl_summary.addMouseListener(new MouseAdapter()
343 public void mousePressed(MouseEvent e)
347 super.mousePressed(e);
352 public void mouseClicked(MouseEvent e)
356 validateSelections();
361 public void mouseReleased(MouseEvent e)
365 validateSelections();
369 boolean popupAction(MouseEvent e)
371 if (e.isPopupTrigger())
373 Point pt = e.getPoint();
374 int selectedRow = tbl_summary.rowAtPoint(pt);
375 if (showPopupFor(selectedRow, pt.x, pt.y))
383 tbl_summary.addKeyListener(new KeyAdapter()
386 public void keyPressed(KeyEvent evt)
388 validateSelections();
389 switch (evt.getKeyCode())
391 case KeyEvent.VK_ESCAPE: // escape key
394 case KeyEvent.VK_ENTER: // enter key
395 if (btn_add.isEnabled())
397 add_ActionPerformed();
400 case KeyEvent.VK_TAB: // tab key
401 if (evt.isShiftDown())
403 pnl_filter.requestFocus();
407 btn_add.requestFocus();
417 JButton btn_cancel = new JButton(
418 MessageManager.getString("action.cancel"));
419 btn_cancel.setFont(VERDANA_12);
420 btn_cancel.addActionListener(new ActionListener()
423 public void actionPerformed(ActionEvent e)
425 closeAction(pnl_filter.getHeight());
428 btn_cancel.addKeyListener(new KeyAdapter()
431 public void keyPressed(KeyEvent evt)
433 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
435 closeAction(pnl_filter.getHeight());
440 tbl_local_pdb.setAutoCreateRowSorter(true);
441 tbl_local_pdb.getTableHeader().setReorderingAllowed(false);
442 tbl_local_pdb.addMouseListener(new MouseAdapter()
445 public void mouseClicked(MouseEvent e)
447 validateSelections();
451 public void mouseReleased(MouseEvent e)
453 validateSelections();
456 tbl_local_pdb.addKeyListener(new KeyAdapter()
459 public void keyPressed(KeyEvent evt)
461 validateSelections();
462 switch (evt.getKeyCode())
464 case KeyEvent.VK_ESCAPE: // escape key
467 case KeyEvent.VK_ENTER: // enter key
468 if (btn_add.isEnabled())
470 add_ActionPerformed();
473 case KeyEvent.VK_TAB: // tab key
474 if (evt.isShiftDown())
476 cmb_filterOption.requestFocus();
480 if (btn_add.isEnabled())
482 btn_add.requestFocus();
486 btn_cancel.requestFocus();
497 btn_newView = new JButton(
498 MessageManager.formatMessage("action.new_structure_view_with",
499 StructureViewer.getViewerType().toString()));
500 btn_newView.setFont(VERDANA_12);
501 btn_newView.addActionListener(new ActionListener()
504 public void actionPerformed(ActionEvent e)
506 newView_ActionPerformed();
509 btn_newView.addKeyListener(new KeyAdapter()
512 public void keyPressed(KeyEvent evt)
514 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
516 newView_ActionPerformed();
521 // TODO: JAL-3898 - get list of available external programs to view
524 btn_add = new JButton(MessageManager.getString("action.add"));
525 btn_add.setFont(VERDANA_12);
526 btn_add.addActionListener(new ActionListener()
529 public void actionPerformed(ActionEvent e)
531 add_ActionPerformed();
534 btn_add.addKeyListener(new KeyAdapter()
537 public void keyPressed(KeyEvent evt)
539 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
541 add_ActionPerformed();
546 btn_pdbFromFile.setFont(VERDANA_12);
547 String btn_title = MessageManager.getString("label.select_pdb_file");
548 btn_pdbFromFile.setText(btn_title + " ");
549 btn_pdbFromFile.addActionListener(new ActionListener()
552 public void actionPerformed(ActionEvent e)
554 pdbFromFile_actionPerformed();
557 btn_pdbFromFile.addKeyListener(new KeyAdapter()
560 public void keyPressed(KeyEvent evt)
562 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
564 pdbFromFile_actionPerformed();
568 lbl_pdbFile.setFont(VERDANA_10);
569 lbl_pdbFile.setFont(VERDANA_10);
571 lbl_chooseTempFacType.setFont(VERDANA_12);
572 lbl_chooseTempFacType.setText(new StringBuilder()
573 .append(MessageManager.getString("label.choose_tempfac_type"))
574 .append(" ").append(MessageManager.getString("label.optional"))
577 combo_tempFacAs.setFont(VERDANA_12);
578 for (TFType t : TFType.values())
580 combo_tempFacAs.addItem(t);
582 combo_tempFacAs.addItemListener(new ItemListener()
585 public void itemStateChanged(ItemEvent e)
587 // used to determine if we should guess pLDDT or leave a user-choice
588 tempFacAsChanged = true;
592 btn_paeMatrixFile.setFont(VERDANA_12);
593 btn_paeMatrixFile.setText(new StringBuilder()
594 .append(MessageManager.getString("label.add_pae_matrix_file"))
595 .append(" ").append(MessageManager.getString("label.optional"))
597 btn_paeMatrixFile.addActionListener(new ActionListener()
600 public void actionPerformed(ActionEvent e)
602 paeMatrixFile_actionPerformed();
605 btn_paeMatrixFile.addKeyListener(new KeyAdapter()
608 public void keyPressed(KeyEvent evt)
610 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
612 paeMatrixFile_actionPerformed();
616 lbl_paeFile.setFont(VERDANA_10);
618 JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary);
619 scrl_foundStructures.setPreferredSize(new Dimension(width, height));
621 JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
622 scrl_localPDB.setPreferredSize(new Dimension(width, height));
623 scrl_localPDB.setHorizontalScrollBarPolicy(
624 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
626 chk_invertFilter.setFont(VERDANA_12);
627 txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true,
628 MessageManager.getString("label.enter_pdb_id_tip")));
629 txt_search.getDocument().addDocumentListener(new DocumentListener()
632 public void insertUpdate(DocumentEvent e)
634 txt_search_ActionPerformedDelayed();
638 public void removeUpdate(DocumentEvent e)
640 txt_search_ActionPerformedDelayed();
644 public void changedUpdate(DocumentEvent e)
646 txt_search_ActionPerformedDelayed();
650 cmb_filterOption.setFont(VERDANA_12);
651 cmb_filterOption.setToolTipText(
652 MessageManager.getString("info.select_filter_option"));
653 cmb_filterOption.addItemListener(this);
654 // add CustomComboSeparatorsRenderer to filter option combo-box
655 cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer(
656 (ListCellRenderer<Object>) cmb_filterOption.getRenderer())
659 protected boolean addSeparatorAfter(JList list, FilterOption value,
662 return value.isAddSeparatorAfter();
666 chk_invertFilter.addItemListener(this);
667 btn_queryTDB = new JButton();
668 if (Platform.isMac())
670 // needed to make icon button have round corners in vaqua
671 btn_queryTDB.putClientProperty("JButton.buttonType", "bevel");
673 btn_queryTDB.setMargin(new Insets(0, 16, 0, 20));
675 .setText(MessageManager.getString("label.search_3dbeacons"));
676 btn_queryTDB.setIconTextGap(12);
677 btn_queryTDB.setIcon(tdbImage);
678 btn_queryTDB.setVerticalTextPosition(SwingConstants.CENTER);
679 btn_queryTDB.setHorizontalTextPosition(SwingConstants.TRAILING);
680 btn_queryTDB.setFont(VERDANA_12);
681 btn_queryTDB.setToolTipText(
682 MessageManager.getString("label.find_models_from_3dbeacons"));
683 // btn_queryTDB.setPreferredSize(new Dimension(200, 32));
684 btn_queryTDB.setVisible(false);
686 targetView.setVisible(false);
688 JPanel actionsPanel = new JPanel(new MigLayout());
689 actionsPanel.add(targetView, "left");
690 actionsPanel.add(btn_add, "wrap");
691 actionsPanel.add(chk_superpose, "left");
692 actionsPanel.add(btn_newView);
693 actionsPanel.add(btn_cancel, "right");
695 JPanel pnl_main = new JPanel(new BorderLayout());
696 JPanel pnl_controls = new JPanel();
697 pnl_queryTDB = new JPanel();
698 pnl_queryTDB.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4));
699 pnl_queryTDB.setBackground(getBackground());
700 pnl_queryTDB.add(btn_queryTDB);
702 pnl_queryTDB.setVisible(false);
703 pnl_main.add(pnl_queryTDB, BorderLayout.NORTH);
704 pnl_controls.add(cmb_filterOption);
705 pnl_controls.add(lbl_loading);
706 pnl_controls.add(chk_invertFilter);
707 pnl_main.add(pnl_controls, BorderLayout.CENTER);
708 lbl_loading.setVisible(false);
710 // JPanel pnl_fileChooser = new JPanel(new FlowLayout());
711 // pnl_fileChooser.add(btn_pdbFromFile);
712 // pnl_fileChooser.add(lbl_fromFileStatus);
714 JPanel pnl_fileOptions = new JPanel();
715 pnl_fileOptions.setLayout(new GridBagLayout());
716 GridBagConstraints gbc = new GridBagConstraints();
721 gbc.insets = new Insets(0, 0, 2, 0);
722 gbc.fill = GridBagConstraints.NONE;
723 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
724 // pnl_fileOptions.add(pnl_fileChooser, gbc);
725 pnl_fileOptions.add(btn_pdbFromFile, gbc);
727 gbc.insets = new Insets(0, 0, 18, 0);
728 pnl_fileOptions.add(lbl_pdbFile, gbc);
730 gbc.insets = new Insets(0, 0, 2, 0);
731 pnl_fileOptions.add(lbl_chooseTempFacType, gbc);
733 gbc.insets = new Insets(0, 0, 18, 0);
734 pnl_fileOptions.add(combo_tempFacAs, gbc);
736 gbc.insets = new Insets(0, 0, 2, 0);
737 pnl_fileOptions.add(btn_paeMatrixFile, gbc);
740 pnl_fileOptions.add(lbl_paeFile, gbc);
742 JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
743 pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.PAGE_START);
744 pnl_fileChooserBL.add(pnl_fileOptions, BorderLayout.CENTER);
746 JPanel pnl_idInput = new JPanel(new FlowLayout());
747 pnl_idInput.add(txt_search);
748 pnl_idInput.add(lbl_pdbManualFetchStatus);
750 JPanel pnl_idInputBL = new JPanel(new BorderLayout());
751 pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH);
752 pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER);
754 final String foundStructureSummary = MessageManager
755 .getString("label.found_structures_summary");
756 final String configureCols = MessageManager
757 .getString("label.configure_displayed_columns");
758 ChangeListener changeListener = new ChangeListener()
761 public void stateChanged(ChangeEvent changeEvent)
763 JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
765 int index = sourceTabbedPane.getSelectedIndex();
766 btn_add.setVisible(targetView.isVisible());
767 btn_newView.setVisible(true);
768 btn_cancel.setVisible(true);
769 if (sourceTabbedPane.getTitleAt(index).equals(configureCols))
771 btn_add.setEnabled(false);
772 btn_cancel.setEnabled(false);
773 btn_add.setVisible(false);
774 btn_newView.setEnabled(false);
775 btn_cancel.setVisible(false);
776 previousWantedFields = getFTSDocFieldPrefs()
777 .getStructureSummaryFields()
778 .toArray(new FTSDataColumnI[0]);
780 if (sourceTabbedPane.getTitleAt(index)
781 .equals(foundStructureSummary))
783 btn_cancel.setEnabled(true);
784 if (wantedFieldsUpdated())
790 validateSelections();
795 pnl_filter.addChangeListener(changeListener);
796 pnl_filter.setPreferredSize(new Dimension(width, height));
797 pnl_filter.add(foundStructureSummary, scrl_foundStructures);
798 pnl_filter.add(configureCols, getFTSDocFieldPrefs());
800 JPanel pnl_locPDB = new JPanel(new BorderLayout());
801 pnl_locPDB.add(scrl_localPDB);
803 pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE);
804 pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID);
805 pnl_switchableViews.add(pnl_filter, VIEWS_FILTER);
806 pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB);
808 this.setLayout(new BorderLayout());
809 this.add(pnl_main, java.awt.BorderLayout.NORTH);
810 this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER);
811 // this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
812 statusPanel.setLayout(new GridLayout());
814 JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout());
815 pnl_actionsAndStatus.add(actionsPanel, BorderLayout.CENTER);
816 pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH);
817 statusPanel.add(statusBar, null);
818 this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH);
820 mainFrame.addInternalFrameListener(
821 new javax.swing.event.InternalFrameAdapter()
824 public void internalFrameClosing(InternalFrameEvent e)
826 closeAction(pnl_filter.getHeight());
829 mainFrame.setVisible(true);
830 mainFrame.setContentPane(this);
831 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
832 Integer x = tempUserPrefs.get("structureChooser.x");
833 Integer y = tempUserPrefs.get("structureChooser.y");
834 if (x != null && y != null)
836 mainFrame.setLocation(x, y);
838 Desktop.addInternalFrame(mainFrame, frameTitle, width, height);
841 protected abstract boolean showPopupFor(int selectedRow, int x, int y);
843 protected void closeAction(int preferredHeight)
845 // System.out.println(">>>>>>>>>> closing internal frame!!!");
846 // System.out.println("width : " + mainFrame.getWidth());
847 // System.out.println("heigh : " + mainFrame.getHeight());
848 // System.out.println("x : " + mainFrame.getX());
849 // System.out.println("y : " + mainFrame.getY());
850 tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth());
851 tempUserPrefs.put("structureChooser.height", preferredHeight);
852 tempUserPrefs.put("structureChooser.x", mainFrame.getX());
853 tempUserPrefs.put("structureChooser.y", mainFrame.getY());
857 public boolean wantedFieldsUpdated()
859 if (previousWantedFields == null)
864 FTSDataColumnI[] currentWantedFields = getFTSDocFieldPrefs()
865 .getStructureSummaryFields().toArray(new FTSDataColumnI[0]);
866 return Arrays.equals(currentWantedFields, previousWantedFields) ? false
873 * Event listener for the 'filter' combo-box and 'invert' check-box
875 public void itemStateChanged(ItemEvent e)
881 * This inner class provides the provides the data model for associate
882 * sequence combo-box - cmb_assSeq
887 public class AssociateSeqOptions
889 private SequenceI sequence;
893 public AssociateSeqOptions(SequenceI seq)
896 this.name = (seq.getName().length() >= 23)
897 ? seq.getName().substring(0, 23)
901 public AssociateSeqOptions(String name, SequenceI seq)
908 public String toString()
913 public String getName()
918 public void setName(String name)
923 public SequenceI getSequence()
928 public void setSequence(SequenceI sequence)
930 this.sequence = sequence;
936 * This inner class holds the Layout and configuration of the panel which
937 * handles association of manually fetched structures to a unique sequence
938 * when more than one sequence selection is made
943 public class AssociateSeqPanel extends JPanel implements ItemListener
945 private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<>();
947 private JLabel lbl_associateSeq = new JLabel();
949 public AssociateSeqPanel()
951 this.setLayout(new FlowLayout());
952 this.add(cmb_assSeq);
953 this.add(lbl_associateSeq);
954 cmb_assSeq.setToolTipText(
955 MessageManager.getString("info.associate_wit_sequence"));
956 cmb_assSeq.addItemListener(this);
959 public void loadCmbAssSeq()
961 populateCmbAssociateSeqOptions(cmb_assSeq, lbl_associateSeq);
964 public JComboBox<AssociateSeqOptions> getCmb_assSeq()
969 public void setCmb_assSeq(JComboBox<AssociateSeqOptions> cmb_assSeq)
971 this.cmb_assSeq = cmb_assSeq;
975 public void itemStateChanged(ItemEvent e)
977 if (e.getStateChange() == ItemEvent.SELECTED)
979 cmbAssSeqStateChanged();
984 public JTable getResultTable()
989 public JComboBox<FilterOption> getCmbFilterOption()
991 return cmb_filterOption;
995 * Custom ListCellRenderer for adding a separator between different categories
996 * of structure chooser filter option drop-down.
1001 public abstract class CustomComboSeparatorsRenderer
1002 implements ListCellRenderer<Object>
1004 private ListCellRenderer<Object> regent;
1006 private JPanel separatorPanel = new JPanel(new BorderLayout());
1008 private JSeparator jSeparator = new JSeparator();
1010 public CustomComboSeparatorsRenderer(
1011 ListCellRenderer<Object> listCellRenderer)
1013 this.regent = listCellRenderer;
1017 public Component getListCellRendererComponent(JList list, Object value,
1018 int index, boolean isSelected, boolean cellHasFocus)
1021 Component comp = regent.getListCellRendererComponent(list, value,
1022 index, isSelected, cellHasFocus);
1024 && addSeparatorAfter(list, (FilterOption) value, index))
1026 separatorPanel.removeAll();
1027 separatorPanel.add(comp, BorderLayout.CENTER);
1028 separatorPanel.add(jSeparator, BorderLayout.SOUTH);
1029 return separatorPanel;
1037 protected abstract boolean addSeparatorAfter(JList list,
1038 FilterOption value, int index);
1041 protected abstract void stateChanged(ItemEvent e);
1043 protected abstract void add_ActionPerformed();
1045 protected abstract void newView_ActionPerformed();
1047 protected abstract void pdbFromFile_actionPerformed();
1049 protected abstract void paeMatrixFile_actionPerformed();
1051 protected abstract void txt_search_ActionPerformed();
1053 protected abstract void populateCmbAssociateSeqOptions(
1054 JComboBox<AssociateSeqOptions> cmb_assSeq,
1055 JLabel lbl_associateSeq);
1057 protected abstract void cmbAssSeqStateChanged();
1059 protected abstract void tabRefresh();
1061 protected abstract void validateSelections();
1063 public JInternalFrame getFrame()
1068 public void setPdbOptionsEnabled(boolean b)
1070 lbl_chooseTempFacType.setEnabled(b);
1071 combo_tempFacAs.setEnabled(b);
1072 btn_paeMatrixFile.setEnabled(b);