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 actionsPanel;
111 protected JPanel statusPanel = new JPanel();
113 public JLabel statusBar = new JLabel();
115 protected String frameTitle = MessageManager
116 .getString("label.structure_chooser");
118 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
120 protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<>();
122 protected AlignmentPanel ap;
124 protected StringBuilder errorWarning = new StringBuilder();
126 protected JButton btn_cancel;
128 protected JButton btn_add;
130 protected JButton btn_newView;
132 protected JButton btn_pdbFromFile = new JButton();
134 protected JLabel lbl_pdbFile = new JLabel();
136 protected JLabel lbl_chooseTempFacType = new JLabel();
138 protected JComboBox<StructureImportSettings.TFType> combo_tempFacAs = new JComboBox<>();
140 protected boolean tempFacAsChanged = false;
142 protected JButton btn_paeMatrixFile = new JButton();
144 protected JLabel lbl_paeFile = new JLabel();
146 // holder for icon and button
147 protected JPanel pnl_queryTDB;
149 protected JButton btn_queryTDB = new JButton();
151 protected JCheckBox chk_superpose = new JCheckBox(
152 MessageManager.getString("label.superpose_structures"));
154 protected JTextField txt_search = new JTextField(14);
156 protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
158 protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews
161 protected JCheckBox chk_invertFilter = new JCheckBox(
162 MessageManager.getString("label.invert"));
164 protected ImageIcon loadingImage = new ImageIcon(
165 getClass().getResource("/images/loading.gif"));
167 protected ImageIcon goodImage = new ImageIcon(
168 getClass().getResource("/images/good.png"));
170 protected ImageIcon errorImage = new ImageIcon(
171 getClass().getResource("/images/error.png"));
173 protected ImageIcon warningImage = new ImageIcon(
174 getClass().getResource("/images/warning.gif"));
176 protected ImageIcon tdbImage = new ImageIcon(getClass()
177 .getResource("/images/3d-beacons-logo-transparent.png"));
179 protected JLabel lbl_loading = new JLabel(loadingImage);
181 protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
183 // protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
185 protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel();
187 protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel();
189 protected JComboBox<StructureViewer> targetView = new JComboBox<>();
191 protected JTable tbl_local_pdb = new JTable();
193 protected JTabbedPane pnl_filter = new JTabbedPane();
195 protected abstract FTSDataColumnPreferences getFTSDocFieldPrefs();
197 protected abstract void setFTSDocFieldPrefs(
198 FTSDataColumnPreferences newPrefs);
200 protected FTSDataColumnI[] previousWantedFields;
202 protected static Map<String, Integer> tempUserPrefs = new HashMap<>();
204 private JTable tbl_summary = new JTable()
206 private boolean inLayout;
209 public boolean getScrollableTracksViewportWidth()
211 return hasExcessWidth();
216 public void doLayout()
218 if (hasExcessWidth())
220 autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS;
225 autoResizeMode = AUTO_RESIZE_OFF;
228 protected boolean hasExcessWidth()
230 return getPreferredSize().width < getParent().getWidth();
234 public void columnMarginChanged(ChangeEvent e)
240 TableColumn resizingColumn = getTableHeader().getResizingColumn();
241 // Need to do this here, before the parent's
242 // layout manager calls getPreferredSize().
243 if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF
246 resizingColumn.setPreferredWidth(resizingColumn.getWidth());
247 String colHeader = resizingColumn.getHeaderValue().toString();
248 tempUserPrefs.put(colHeader, resizingColumn.getWidth());
254 public String getToolTipText(MouseEvent evt)
256 String toolTipText = null;
257 java.awt.Point pnt = evt.getPoint();
258 int rowIndex = rowAtPoint(pnt);
259 int colIndex = columnAtPoint(pnt);
263 if (getValueAt(rowIndex, colIndex) == null)
267 toolTipText = getValueAt(rowIndex, colIndex).toString();
268 } catch (Exception e)
270 // e.printStackTrace();
272 toolTipText = (toolTipText == null ? null
273 : (toolTipText.length() > 500
274 ? JvSwingUtils.wrapTooltip(true,
275 "\"" + toolTipText.subSequence(0, 500)
277 : JvSwingUtils.wrapTooltip(true, toolTipText)));
282 public GStructureChooser()
286 protected void initDialog()
292 mainFrame.setFrameIcon(null);
293 mainFrame.setVisible(false);
294 mainFrame.invalidate();
296 } catch (Exception e)
298 jalview.bin.Console.outPrintln(e); // for JavaScript TypeError
303 // BH SwingJS optimization
304 // (a) 100-ms interruptable timer for text entry -- BH 1/10/2019
305 // (b) two-character minimum, at least for JavaScript.
309 protected void txt_search_ActionPerformedDelayed()
315 timer = new Timer(300, new ActionListener()
319 public void actionPerformed(ActionEvent e)
321 txt_search_ActionPerformed();
324 timer.setRepeats(false);
330 * Initializes the GUI default properties
334 private void jbInit() throws Exception
336 Integer width = tempUserPrefs.get("structureChooser.width") == null
338 : tempUserPrefs.get("structureChooser.width");
339 Integer height = tempUserPrefs.get("structureChooser.height") == null
341 : tempUserPrefs.get("structureChooser.height");
342 tbl_summary.setAutoCreateRowSorter(true);
343 tbl_summary.getTableHeader().setReorderingAllowed(false);
344 tbl_summary.addMouseListener(new MouseAdapter()
347 public void mousePressed(MouseEvent e)
351 super.mousePressed(e);
356 public void mouseClicked(MouseEvent e)
360 validateSelections();
365 public void mouseReleased(MouseEvent e)
369 validateSelections();
373 boolean popupAction(MouseEvent e)
375 if (e.isPopupTrigger())
377 Point pt = e.getPoint();
378 int selectedRow = tbl_summary.rowAtPoint(pt);
379 if (showPopupFor(selectedRow, pt.x, pt.y))
387 tbl_summary.addKeyListener(new KeyAdapter()
390 public void keyPressed(KeyEvent evt)
392 validateSelections();
393 switch (evt.getKeyCode())
395 case KeyEvent.VK_ESCAPE: // escape key
398 case KeyEvent.VK_ENTER: // enter key
399 if (btn_add.isEnabled())
401 add_ActionPerformed();
404 case KeyEvent.VK_TAB: // tab key
405 if (evt.isShiftDown())
407 pnl_filter.requestFocus();
411 btn_add.requestFocus();
421 btn_cancel = new JButton(MessageManager.getString("action.cancel"));
422 btn_cancel.setFont(VERDANA_12);
423 btn_cancel.addActionListener(new ActionListener()
426 public void actionPerformed(ActionEvent e)
428 closeAction(pnl_filter.getHeight());
431 btn_cancel.addKeyListener(new KeyAdapter()
434 public void keyPressed(KeyEvent evt)
436 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
438 closeAction(pnl_filter.getHeight());
443 tbl_local_pdb.setAutoCreateRowSorter(true);
444 tbl_local_pdb.getTableHeader().setReorderingAllowed(false);
445 tbl_local_pdb.addMouseListener(new MouseAdapter()
448 public void mouseClicked(MouseEvent e)
450 validateSelections();
454 public void mouseReleased(MouseEvent e)
456 validateSelections();
459 tbl_local_pdb.addKeyListener(new KeyAdapter()
462 public void keyPressed(KeyEvent evt)
464 validateSelections();
465 switch (evt.getKeyCode())
467 case KeyEvent.VK_ESCAPE: // escape key
470 case KeyEvent.VK_ENTER: // enter key
471 if (btn_add.isEnabled())
473 add_ActionPerformed();
476 case KeyEvent.VK_TAB: // tab key
477 if (evt.isShiftDown())
479 cmb_filterOption.requestFocus();
483 if (btn_add.isEnabled())
485 btn_add.requestFocus();
489 btn_cancel.requestFocus();
500 btn_newView = new JButton(
501 MessageManager.formatMessage("action.new_structure_view_with",
502 StructureViewer.getViewerType().toString()));
503 btn_newView.setFont(VERDANA_12);
504 btn_newView.addActionListener(new ActionListener()
507 public void actionPerformed(ActionEvent e)
509 newView_ActionPerformed();
512 btn_newView.addKeyListener(new KeyAdapter()
515 public void keyPressed(KeyEvent evt)
517 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
519 newView_ActionPerformed();
524 // TODO: JAL-3898 - get list of available external programs to view
527 btn_add = new JButton(MessageManager.getString("action.add"));
528 btn_add.setFont(VERDANA_12);
529 btn_add.addActionListener(new ActionListener()
532 public void actionPerformed(ActionEvent e)
534 add_ActionPerformed();
537 btn_add.addKeyListener(new KeyAdapter()
540 public void keyPressed(KeyEvent evt)
542 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
544 add_ActionPerformed();
549 btn_pdbFromFile.setFont(VERDANA_12);
550 String btn_title = MessageManager.getString("label.select_pdb_file");
551 btn_pdbFromFile.setText(btn_title + " ");
552 btn_pdbFromFile.addActionListener(new ActionListener()
555 public void actionPerformed(ActionEvent e)
557 pdbFromFile_actionPerformed();
560 btn_pdbFromFile.addKeyListener(new KeyAdapter()
563 public void keyPressed(KeyEvent evt)
565 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
567 pdbFromFile_actionPerformed();
571 lbl_pdbFile.setFont(VERDANA_10);
572 lbl_pdbFile.setFont(VERDANA_10);
574 lbl_chooseTempFacType.setFont(VERDANA_12);
575 lbl_chooseTempFacType.setText(
576 MessageManager.getString("label.interpret_tempfac_as"));
578 combo_tempFacAs.setFont(VERDANA_12);
579 for (TFType t : TFType.values())
581 combo_tempFacAs.addItem(t);
583 combo_tempFacAs.addItemListener(new ItemListener()
586 public void itemStateChanged(ItemEvent e)
588 // used to determine if we should guess pLDDT or leave a user-choice
589 tempFacAsChanged = true;
593 btn_paeMatrixFile.setFont(VERDANA_12);
595 .setText(MessageManager.getString("label.add_pae_matrix_file"));
596 btn_paeMatrixFile.addActionListener(new ActionListener()
599 public void actionPerformed(ActionEvent e)
601 paeMatrixFile_actionPerformed();
604 btn_paeMatrixFile.addKeyListener(new KeyAdapter()
607 public void keyPressed(KeyEvent evt)
609 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
611 paeMatrixFile_actionPerformed();
615 lbl_paeFile.setFont(VERDANA_10);
617 JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary);
618 scrl_foundStructures.setPreferredSize(new Dimension(width, height));
620 JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
621 scrl_localPDB.setPreferredSize(new Dimension(width, height));
622 scrl_localPDB.setHorizontalScrollBarPolicy(
623 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
625 chk_invertFilter.setFont(VERDANA_12);
626 txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true,
627 MessageManager.getString("label.enter_pdb_id_tip")));
628 txt_search.getDocument().addDocumentListener(new DocumentListener()
631 public void insertUpdate(DocumentEvent e)
633 txt_search_ActionPerformedDelayed();
637 public void removeUpdate(DocumentEvent e)
639 txt_search_ActionPerformedDelayed();
643 public void changedUpdate(DocumentEvent e)
645 txt_search_ActionPerformedDelayed();
649 cmb_filterOption.setFont(VERDANA_12);
650 cmb_filterOption.setToolTipText(
651 MessageManager.getString("info.select_filter_option"));
652 cmb_filterOption.addItemListener(this);
653 // add CustomComboSeparatorsRenderer to filter option combo-box
654 cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer(
655 (ListCellRenderer<Object>) cmb_filterOption.getRenderer())
658 protected boolean addSeparatorAfter(JList list, FilterOption value,
661 return value.isAddSeparatorAfter();
665 chk_invertFilter.addItemListener(this);
666 btn_queryTDB = new JButton();
667 if (Platform.isMac())
669 // needed to make icon button have round corners in vaqua
670 btn_queryTDB.putClientProperty("JButton.buttonType", "bevel");
672 btn_queryTDB.setMargin(new Insets(0, 16, 0, 20));
674 .setText(MessageManager.getString("label.search_3dbeacons"));
675 btn_queryTDB.setIconTextGap(12);
676 btn_queryTDB.setIcon(tdbImage);
677 btn_queryTDB.setVerticalTextPosition(SwingConstants.CENTER);
678 btn_queryTDB.setHorizontalTextPosition(SwingConstants.TRAILING);
679 btn_queryTDB.setFont(VERDANA_12);
680 btn_queryTDB.setToolTipText(
681 MessageManager.getString("label.find_models_from_3dbeacons"));
682 // btn_queryTDB.setPreferredSize(new Dimension(200, 32));
683 btn_queryTDB.setVisible(false);
685 targetView.setVisible(false);
687 actionsPanel = new JPanel(new MigLayout());
688 actionsPanel.add(targetView, "left");
689 actionsPanel.add(btn_add, "wrap");
690 actionsPanel.add(chk_superpose, "left");
691 actionsPanel.add(btn_newView);
692 actionsPanel.add(btn_cancel, "right");
694 JPanel pnl_main = new JPanel(new BorderLayout());
695 JPanel pnl_controls = new JPanel();
696 pnl_queryTDB = new JPanel();
697 pnl_queryTDB.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4));
698 pnl_queryTDB.setBackground(getBackground());
699 pnl_queryTDB.add(btn_queryTDB);
701 pnl_queryTDB.setVisible(false);
702 pnl_main.add(pnl_queryTDB, BorderLayout.NORTH);
703 pnl_controls.add(cmb_filterOption);
704 pnl_controls.add(lbl_loading);
705 pnl_controls.add(chk_invertFilter);
706 pnl_main.add(pnl_controls, BorderLayout.CENTER);
707 lbl_loading.setVisible(false);
709 // JPanel pnl_fileChooser = new JPanel(new FlowLayout());
710 // pnl_fileChooser.add(btn_pdbFromFile);
711 // pnl_fileChooser.add(lbl_fromFileStatus);
713 JPanel pnl_fileOptions = new JPanel();
714 pnl_fileOptions.setLayout(new GridBagLayout());
715 GridBagConstraints gbc = new GridBagConstraints();
720 gbc.insets = new Insets(0, 0, 2, 0);
721 gbc.fill = GridBagConstraints.NONE;
722 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
723 // pnl_fileOptions.add(pnl_fileChooser, gbc);
724 pnl_fileOptions.add(btn_pdbFromFile, gbc);
726 gbc.insets = new Insets(0, 0, 18, 0);
727 pnl_fileOptions.add(lbl_pdbFile, gbc);
730 gbc.insets = new Insets(0, 0, 2, 0);
731 pnl_fileOptions.add(new JLabel(
732 MessageManager.getString("label.structure_import_options")),
736 gbc.insets = new Insets(0, 0, 6, 0);
737 pnl_fileOptions.add(lbl_chooseTempFacType, gbc);
739 gbc.insets = new Insets(0, 0, 18, 0);
740 pnl_fileOptions.add(combo_tempFacAs, gbc);
742 gbc.insets = new Insets(0, 0, 6, 0);
743 pnl_fileOptions.add(btn_paeMatrixFile, gbc);
745 gbc.insets = new Insets(0, 0, 2, 0);
747 pnl_fileOptions.add(lbl_paeFile, gbc);
749 JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
750 pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.PAGE_START);
751 pnl_fileChooserBL.add(pnl_fileOptions, BorderLayout.CENTER);
753 JPanel pnl_idInput = new JPanel(new FlowLayout());
754 pnl_idInput.add(txt_search);
755 pnl_idInput.add(lbl_pdbManualFetchStatus);
757 JPanel pnl_idInputBL = new JPanel(new BorderLayout());
758 pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH);
759 pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER);
761 final String foundStructureSummary = MessageManager
762 .getString("label.found_structures_summary");
763 final String configureCols = MessageManager
764 .getString("label.configure_displayed_columns");
765 ChangeListener changeListener = new ChangeListener()
768 public void stateChanged(ChangeEvent changeEvent)
770 JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
772 int index = sourceTabbedPane.getSelectedIndex();
773 btn_add.setVisible(targetView.isVisible());
774 btn_newView.setVisible(true);
775 btn_cancel.setVisible(true);
776 if (sourceTabbedPane.getTitleAt(index).equals(configureCols))
778 btn_add.setEnabled(false);
779 btn_cancel.setEnabled(false);
780 btn_add.setVisible(false);
781 btn_newView.setEnabled(false);
782 btn_cancel.setVisible(false);
783 previousWantedFields = getFTSDocFieldPrefs()
784 .getStructureSummaryFields()
785 .toArray(new FTSDataColumnI[0]);
787 if (sourceTabbedPane.getTitleAt(index)
788 .equals(foundStructureSummary))
790 btn_cancel.setEnabled(true);
791 if (wantedFieldsUpdated())
797 validateSelections();
802 pnl_filter.addChangeListener(changeListener);
803 pnl_filter.setPreferredSize(new Dimension(width, height));
804 pnl_filter.add(foundStructureSummary, scrl_foundStructures);
805 pnl_filter.add(configureCols, getFTSDocFieldPrefs());
807 JPanel pnl_locPDB = new JPanel(new BorderLayout());
808 pnl_locPDB.add(scrl_localPDB);
810 pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE);
811 pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID);
812 pnl_switchableViews.add(pnl_filter, VIEWS_FILTER);
813 pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB);
815 this.setLayout(new BorderLayout());
816 this.add(pnl_main, java.awt.BorderLayout.NORTH);
817 this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER);
818 // this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
819 statusPanel.setLayout(new GridLayout());
821 JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout());
822 pnl_actionsAndStatus.add(actionsPanel, BorderLayout.CENTER);
823 pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH);
824 statusPanel.add(statusBar, null);
825 this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH);
827 mainFrame.addInternalFrameListener(
828 new javax.swing.event.InternalFrameAdapter()
831 public void internalFrameClosing(InternalFrameEvent e)
833 closeAction(pnl_filter.getHeight());
836 mainFrame.setVisible(true);
837 mainFrame.setContentPane(this);
838 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
839 Integer x = tempUserPrefs.get("structureChooser.x");
840 Integer y = tempUserPrefs.get("structureChooser.y");
841 if (x != null && y != null)
843 mainFrame.setLocation(x, y);
845 Desktop.addInternalFrame(mainFrame, frameTitle, width, height);
848 protected abstract boolean showPopupFor(int selectedRow, int x, int y);
850 protected void closeAction(int preferredHeight)
852 // jalview.bin.Console.outPrintln(">>>>>>>>>> closing internal frame!!!");
853 // jalview.bin.Console.outPrintln("width : " + mainFrame.getWidth());
854 // jalview.bin.Console.outPrintln("heigh : " + mainFrame.getHeight());
855 // jalview.bin.Console.outPrintln("x : " + mainFrame.getX());
856 // jalview.bin.Console.outPrintln("y : " + mainFrame.getY());
857 tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth());
858 tempUserPrefs.put("structureChooser.height", preferredHeight);
859 tempUserPrefs.put("structureChooser.x", mainFrame.getX());
860 tempUserPrefs.put("structureChooser.y", mainFrame.getY());
864 public boolean wantedFieldsUpdated()
866 if (previousWantedFields == null)
871 FTSDataColumnI[] currentWantedFields = getFTSDocFieldPrefs()
872 .getStructureSummaryFields().toArray(new FTSDataColumnI[0]);
873 return Arrays.equals(currentWantedFields, previousWantedFields) ? false
880 * Event listener for the 'filter' combo-box and 'invert' check-box
882 public void itemStateChanged(ItemEvent e)
888 * This inner class provides the provides the data model for associate
889 * sequence combo-box - cmb_assSeq
894 public class AssociateSeqOptions
896 private SequenceI sequence;
900 public AssociateSeqOptions(SequenceI seq)
903 this.name = (seq.getName().length() >= 23)
904 ? seq.getName().substring(0, 23)
908 public AssociateSeqOptions(String name, SequenceI seq)
915 public String toString()
920 public String getName()
925 public void setName(String name)
930 public SequenceI getSequence()
935 public void setSequence(SequenceI sequence)
937 this.sequence = sequence;
943 * This inner class holds the Layout and configuration of the panel which
944 * handles association of manually fetched structures to a unique sequence
945 * when more than one sequence selection is made
950 public class AssociateSeqPanel extends JPanel implements ItemListener
952 private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<>();
954 private JLabel lbl_associateSeq = new JLabel();
956 public AssociateSeqPanel()
958 this.setLayout(new FlowLayout());
959 this.add(cmb_assSeq);
960 this.add(lbl_associateSeq);
961 cmb_assSeq.setToolTipText(
962 MessageManager.getString("info.associate_wit_sequence"));
963 cmb_assSeq.addItemListener(this);
966 public void loadCmbAssSeq()
968 populateCmbAssociateSeqOptions(cmb_assSeq, lbl_associateSeq);
971 public JComboBox<AssociateSeqOptions> getCmb_assSeq()
976 public void setCmb_assSeq(JComboBox<AssociateSeqOptions> cmb_assSeq)
978 this.cmb_assSeq = cmb_assSeq;
982 public void itemStateChanged(ItemEvent e)
984 if (e.getStateChange() == ItemEvent.SELECTED)
986 cmbAssSeqStateChanged();
991 public JTable getResultTable()
996 public JComboBox<FilterOption> getCmbFilterOption()
998 return cmb_filterOption;
1002 * Custom ListCellRenderer for adding a separator between different categories
1003 * of structure chooser filter option drop-down.
1005 * @author tcnofoegbu
1008 public abstract class CustomComboSeparatorsRenderer
1009 implements ListCellRenderer<Object>
1011 private ListCellRenderer<Object> regent;
1013 private JPanel separatorPanel = new JPanel(new BorderLayout());
1015 private JSeparator jSeparator = new JSeparator();
1017 public CustomComboSeparatorsRenderer(
1018 ListCellRenderer<Object> listCellRenderer)
1020 this.regent = listCellRenderer;
1024 public Component getListCellRendererComponent(JList list, Object value,
1025 int index, boolean isSelected, boolean cellHasFocus)
1028 Component comp = regent.getListCellRendererComponent(list, value,
1029 index, isSelected, cellHasFocus);
1031 && addSeparatorAfter(list, (FilterOption) value, index))
1033 separatorPanel.removeAll();
1034 separatorPanel.add(comp, BorderLayout.CENTER);
1035 separatorPanel.add(jSeparator, BorderLayout.SOUTH);
1036 return separatorPanel;
1044 protected abstract boolean addSeparatorAfter(JList list,
1045 FilterOption value, int index);
1048 protected abstract void stateChanged(ItemEvent e);
1050 protected abstract void add_ActionPerformed();
1052 protected abstract void newView_ActionPerformed();
1054 protected abstract void pdbFromFile_actionPerformed();
1056 protected abstract void paeMatrixFile_actionPerformed();
1058 protected abstract void txt_search_ActionPerformed();
1060 protected abstract void populateCmbAssociateSeqOptions(
1061 JComboBox<AssociateSeqOptions> cmb_assSeq,
1062 JLabel lbl_associateSeq);
1064 protected abstract void cmbAssSeqStateChanged();
1066 protected abstract void tabRefresh();
1068 protected abstract void validateSelections();
1070 public JInternalFrame getFrame()
1075 public void setPdbOptionsEnabled(boolean b)
1077 lbl_chooseTempFacType.setEnabled(b);
1078 combo_tempFacAs.setEnabled(b);
1079 btn_paeMatrixFile.setEnabled(b);
1080 lbl_paeFile.setEnabled(b);