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 JButton btn_paeMatrixFile = new JButton();
138 protected JLabel lbl_paeFile = new JLabel();
140 // holder for icon and button
141 protected JPanel pnl_queryTDB;
143 protected JButton btn_queryTDB = new JButton();
145 protected JCheckBox chk_superpose = new JCheckBox(
146 MessageManager.getString("label.superpose_structures"));
148 protected JTextField txt_search = new JTextField(14);
150 protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
152 protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews
155 protected JCheckBox chk_invertFilter = new JCheckBox(
156 MessageManager.getString("label.invert"));
158 protected ImageIcon loadingImage = new ImageIcon(
159 getClass().getResource("/images/loading.gif"));
161 protected ImageIcon goodImage = new ImageIcon(
162 getClass().getResource("/images/good.png"));
164 protected ImageIcon errorImage = new ImageIcon(
165 getClass().getResource("/images/error.png"));
167 protected ImageIcon warningImage = new ImageIcon(
168 getClass().getResource("/images/warning.gif"));
170 protected ImageIcon tdbImage = new ImageIcon(getClass()
171 .getResource("/images/3d-beacons-logo-transparent.png"));
173 protected JLabel lbl_loading = new JLabel(loadingImage);
175 protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
177 // protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
179 protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel();
181 protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel();
183 protected JComboBox<StructureViewer> targetView = new JComboBox<>();
185 protected JTable tbl_local_pdb = new JTable();
187 protected JTabbedPane pnl_filter = new JTabbedPane();
189 protected abstract FTSDataColumnPreferences getFTSDocFieldPrefs();
191 protected abstract void setFTSDocFieldPrefs(
192 FTSDataColumnPreferences newPrefs);
194 protected FTSDataColumnI[] previousWantedFields;
196 protected static Map<String, Integer> tempUserPrefs = new HashMap<>();
198 private JTable tbl_summary = new JTable()
200 private boolean inLayout;
203 public boolean getScrollableTracksViewportWidth()
205 return hasExcessWidth();
210 public void doLayout()
212 if (hasExcessWidth())
214 autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS;
219 autoResizeMode = AUTO_RESIZE_OFF;
222 protected boolean hasExcessWidth()
224 return getPreferredSize().width < getParent().getWidth();
228 public void columnMarginChanged(ChangeEvent e)
234 TableColumn resizingColumn = getTableHeader().getResizingColumn();
235 // Need to do this here, before the parent's
236 // layout manager calls getPreferredSize().
237 if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF
240 resizingColumn.setPreferredWidth(resizingColumn.getWidth());
241 String colHeader = resizingColumn.getHeaderValue().toString();
242 tempUserPrefs.put(colHeader, resizingColumn.getWidth());
248 public String getToolTipText(MouseEvent evt)
250 String toolTipText = null;
251 java.awt.Point pnt = evt.getPoint();
252 int rowIndex = rowAtPoint(pnt);
253 int colIndex = columnAtPoint(pnt);
257 if (getValueAt(rowIndex, colIndex) == null)
261 toolTipText = getValueAt(rowIndex, colIndex).toString();
262 } catch (Exception e)
264 // e.printStackTrace();
266 toolTipText = (toolTipText == null ? null
267 : (toolTipText.length() > 500
268 ? JvSwingUtils.wrapTooltip(true,
269 "\"" + toolTipText.subSequence(0, 500)
271 : JvSwingUtils.wrapTooltip(true, toolTipText)));
276 public GStructureChooser()
280 protected void initDialog()
286 mainFrame.setFrameIcon(null);
287 mainFrame.setVisible(false);
288 mainFrame.invalidate();
290 } catch (Exception e)
292 System.out.println(e); // for JavaScript TypeError
297 // BH SwingJS optimization
298 // (a) 100-ms interruptable timer for text entry -- BH 1/10/2019
299 // (b) two-character minimum, at least for JavaScript.
303 protected void txt_search_ActionPerformedDelayed()
309 timer = new Timer(300, new ActionListener()
313 public void actionPerformed(ActionEvent e)
315 txt_search_ActionPerformed();
318 timer.setRepeats(false);
324 * Initializes the GUI default properties
328 private void jbInit() throws Exception
330 Integer width = tempUserPrefs.get("structureChooser.width") == null
332 : tempUserPrefs.get("structureChooser.width");
333 Integer height = tempUserPrefs.get("structureChooser.height") == null
335 : tempUserPrefs.get("structureChooser.height");
336 tbl_summary.setAutoCreateRowSorter(true);
337 tbl_summary.getTableHeader().setReorderingAllowed(false);
338 tbl_summary.addMouseListener(new MouseAdapter()
341 public void mousePressed(MouseEvent e)
345 super.mousePressed(e);
350 public void mouseClicked(MouseEvent e)
354 validateSelections();
359 public void mouseReleased(MouseEvent e)
363 validateSelections();
367 boolean popupAction(MouseEvent e)
369 if (e.isPopupTrigger())
371 Point pt = e.getPoint();
372 int selectedRow = tbl_summary.rowAtPoint(pt);
373 if (showPopupFor(selectedRow, pt.x, pt.y))
381 tbl_summary.addKeyListener(new KeyAdapter()
384 public void keyPressed(KeyEvent evt)
386 validateSelections();
387 switch (evt.getKeyCode())
389 case KeyEvent.VK_ESCAPE: // escape key
392 case KeyEvent.VK_ENTER: // enter key
393 if (btn_add.isEnabled())
395 add_ActionPerformed();
398 case KeyEvent.VK_TAB: // tab key
399 if (evt.isShiftDown())
401 pnl_filter.requestFocus();
405 btn_add.requestFocus();
415 JButton btn_cancel = new JButton(
416 MessageManager.getString("action.cancel"));
417 btn_cancel.setFont(VERDANA_12);
418 btn_cancel.addActionListener(new ActionListener()
421 public void actionPerformed(ActionEvent e)
423 closeAction(pnl_filter.getHeight());
426 btn_cancel.addKeyListener(new KeyAdapter()
429 public void keyPressed(KeyEvent evt)
431 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
433 closeAction(pnl_filter.getHeight());
438 tbl_local_pdb.setAutoCreateRowSorter(true);
439 tbl_local_pdb.getTableHeader().setReorderingAllowed(false);
440 tbl_local_pdb.addMouseListener(new MouseAdapter()
443 public void mouseClicked(MouseEvent e)
445 validateSelections();
449 public void mouseReleased(MouseEvent e)
451 validateSelections();
454 tbl_local_pdb.addKeyListener(new KeyAdapter()
457 public void keyPressed(KeyEvent evt)
459 validateSelections();
460 switch (evt.getKeyCode())
462 case KeyEvent.VK_ESCAPE: // escape key
465 case KeyEvent.VK_ENTER: // enter key
466 if (btn_add.isEnabled())
468 add_ActionPerformed();
471 case KeyEvent.VK_TAB: // tab key
472 if (evt.isShiftDown())
474 cmb_filterOption.requestFocus();
478 if (btn_add.isEnabled())
480 btn_add.requestFocus();
484 btn_cancel.requestFocus();
495 btn_newView = new JButton(
496 MessageManager.formatMessage("action.new_structure_view_with",
497 StructureViewer.getViewerType().toString()));
498 btn_newView.setFont(VERDANA_12);
499 btn_newView.addActionListener(new ActionListener()
502 public void actionPerformed(ActionEvent e)
504 newView_ActionPerformed();
507 btn_newView.addKeyListener(new KeyAdapter()
510 public void keyPressed(KeyEvent evt)
512 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
514 newView_ActionPerformed();
519 // TODO: JAL-3898 - get list of available external programs to view
522 btn_add = new JButton(MessageManager.getString("action.add"));
523 btn_add.setFont(VERDANA_12);
524 btn_add.addActionListener(new ActionListener()
527 public void actionPerformed(ActionEvent e)
529 add_ActionPerformed();
532 btn_add.addKeyListener(new KeyAdapter()
535 public void keyPressed(KeyEvent evt)
537 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
539 add_ActionPerformed();
544 btn_pdbFromFile.setFont(VERDANA_12);
545 String btn_title = MessageManager.getString("label.select_pdb_file");
546 btn_pdbFromFile.setText(btn_title + " ");
547 btn_pdbFromFile.addActionListener(new ActionListener()
550 public void actionPerformed(ActionEvent e)
552 pdbFromFile_actionPerformed();
555 btn_pdbFromFile.addKeyListener(new KeyAdapter()
558 public void keyPressed(KeyEvent evt)
560 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
562 pdbFromFile_actionPerformed();
566 lbl_pdbFile.setFont(VERDANA_10);
567 lbl_pdbFile.setFont(VERDANA_10);
569 lbl_chooseTempFacType.setFont(VERDANA_12);
570 lbl_chooseTempFacType.setText(new StringBuilder()
571 .append(MessageManager.getString("label.choose_tempfac_type"))
572 .append(" ").append(MessageManager.getString("label.optional"))
575 combo_tempFacAs.setFont(VERDANA_12);
576 for (TFType t : TFType.values())
578 combo_tempFacAs.addItem(t);
581 btn_paeMatrixFile.setFont(VERDANA_12);
582 btn_paeMatrixFile.setText(new StringBuilder()
583 .append(MessageManager.getString("label.add_pae_matrix_file"))
584 .append(" ").append(MessageManager.getString("label.optional"))
586 btn_paeMatrixFile.addActionListener(new ActionListener()
589 public void actionPerformed(ActionEvent e)
591 paeMatrixFile_actionPerformed();
594 btn_paeMatrixFile.addKeyListener(new KeyAdapter()
597 public void keyPressed(KeyEvent evt)
599 if (evt.getKeyCode() == KeyEvent.VK_ENTER)
601 paeMatrixFile_actionPerformed();
605 lbl_paeFile.setFont(VERDANA_10);
607 JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary);
608 scrl_foundStructures.setPreferredSize(new Dimension(width, height));
610 JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
611 scrl_localPDB.setPreferredSize(new Dimension(width, height));
612 scrl_localPDB.setHorizontalScrollBarPolicy(
613 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
615 chk_invertFilter.setFont(VERDANA_12);
616 txt_search.setToolTipText(JvSwingUtils.wrapTooltip(true,
617 MessageManager.getString("label.enter_pdb_id_tip")));
618 txt_search.getDocument().addDocumentListener(new DocumentListener()
621 public void insertUpdate(DocumentEvent e)
623 txt_search_ActionPerformedDelayed();
627 public void removeUpdate(DocumentEvent e)
629 txt_search_ActionPerformedDelayed();
633 public void changedUpdate(DocumentEvent e)
635 txt_search_ActionPerformedDelayed();
639 cmb_filterOption.setFont(VERDANA_12);
640 cmb_filterOption.setToolTipText(
641 MessageManager.getString("info.select_filter_option"));
642 cmb_filterOption.addItemListener(this);
643 // add CustomComboSeparatorsRenderer to filter option combo-box
644 cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer(
645 (ListCellRenderer<Object>) cmb_filterOption.getRenderer())
648 protected boolean addSeparatorAfter(JList list, FilterOption value,
651 return value.isAddSeparatorAfter();
655 chk_invertFilter.addItemListener(this);
656 btn_queryTDB = new JButton();
657 if (Platform.isMac())
659 // needed to make icon button have round corners in vaqua
660 btn_queryTDB.putClientProperty("JButton.buttonType", "bevel");
662 btn_queryTDB.setMargin(new Insets(0, 16, 0, 20));
664 .setText(MessageManager.getString("label.search_3dbeacons"));
665 btn_queryTDB.setIconTextGap(12);
666 btn_queryTDB.setIcon(tdbImage);
667 btn_queryTDB.setVerticalTextPosition(SwingConstants.CENTER);
668 btn_queryTDB.setHorizontalTextPosition(SwingConstants.TRAILING);
669 btn_queryTDB.setFont(VERDANA_12);
670 btn_queryTDB.setToolTipText(
671 MessageManager.getString("label.find_models_from_3dbeacons"));
672 // btn_queryTDB.setPreferredSize(new Dimension(200, 32));
673 btn_queryTDB.setVisible(false);
675 targetView.setVisible(false);
677 JPanel actionsPanel = new JPanel(new MigLayout());
678 actionsPanel.add(targetView, "left");
679 actionsPanel.add(btn_add, "wrap");
680 actionsPanel.add(chk_superpose, "left");
681 actionsPanel.add(btn_newView);
682 actionsPanel.add(btn_cancel, "right");
684 JPanel pnl_main = new JPanel(new BorderLayout());
685 JPanel pnl_controls = new JPanel();
686 pnl_queryTDB = new JPanel();
687 pnl_queryTDB.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4));
688 pnl_queryTDB.setBackground(getBackground());
689 pnl_queryTDB.add(btn_queryTDB);
691 pnl_queryTDB.setVisible(false);
692 pnl_main.add(pnl_queryTDB, BorderLayout.NORTH);
693 pnl_controls.add(cmb_filterOption);
694 pnl_controls.add(lbl_loading);
695 pnl_controls.add(chk_invertFilter);
696 pnl_main.add(pnl_controls, BorderLayout.CENTER);
697 lbl_loading.setVisible(false);
699 // JPanel pnl_fileChooser = new JPanel(new FlowLayout());
700 // pnl_fileChooser.add(btn_pdbFromFile);
701 // pnl_fileChooser.add(lbl_fromFileStatus);
703 JPanel pnl_fileOptions = new JPanel();
704 pnl_fileOptions.setLayout(new GridBagLayout());
705 GridBagConstraints gbc = new GridBagConstraints();
710 gbc.insets = new Insets(0, 0, 2, 0);
711 gbc.fill = GridBagConstraints.NONE;
712 gbc.anchor = GridBagConstraints.FIRST_LINE_START;
713 // pnl_fileOptions.add(pnl_fileChooser, gbc);
714 pnl_fileOptions.add(btn_pdbFromFile, gbc);
716 gbc.insets = new Insets(0, 0, 18, 0);
717 pnl_fileOptions.add(lbl_pdbFile, gbc);
719 gbc.insets = new Insets(0, 0, 2, 0);
720 pnl_fileOptions.add(lbl_chooseTempFacType, gbc);
722 gbc.insets = new Insets(0, 0, 18, 0);
723 pnl_fileOptions.add(combo_tempFacAs, gbc);
725 gbc.insets = new Insets(0, 0, 2, 0);
726 pnl_fileOptions.add(btn_paeMatrixFile, gbc);
729 pnl_fileOptions.add(lbl_paeFile, gbc);
731 JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
732 pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.PAGE_START);
733 pnl_fileChooserBL.add(pnl_fileOptions, BorderLayout.CENTER);
735 JPanel pnl_idInput = new JPanel(new FlowLayout());
736 pnl_idInput.add(txt_search);
737 pnl_idInput.add(lbl_pdbManualFetchStatus);
739 JPanel pnl_idInputBL = new JPanel(new BorderLayout());
740 pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH);
741 pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER);
743 final String foundStructureSummary = MessageManager
744 .getString("label.found_structures_summary");
745 final String configureCols = MessageManager
746 .getString("label.configure_displayed_columns");
747 ChangeListener changeListener = new ChangeListener()
750 public void stateChanged(ChangeEvent changeEvent)
752 JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
754 int index = sourceTabbedPane.getSelectedIndex();
755 btn_add.setVisible(targetView.isVisible());
756 btn_newView.setVisible(true);
757 btn_cancel.setVisible(true);
758 if (sourceTabbedPane.getTitleAt(index).equals(configureCols))
760 btn_add.setEnabled(false);
761 btn_cancel.setEnabled(false);
762 btn_add.setVisible(false);
763 btn_newView.setEnabled(false);
764 btn_cancel.setVisible(false);
765 previousWantedFields = getFTSDocFieldPrefs()
766 .getStructureSummaryFields()
767 .toArray(new FTSDataColumnI[0]);
769 if (sourceTabbedPane.getTitleAt(index)
770 .equals(foundStructureSummary))
772 btn_cancel.setEnabled(true);
773 if (wantedFieldsUpdated())
779 validateSelections();
784 pnl_filter.addChangeListener(changeListener);
785 pnl_filter.setPreferredSize(new Dimension(width, height));
786 pnl_filter.add(foundStructureSummary, scrl_foundStructures);
787 pnl_filter.add(configureCols, getFTSDocFieldPrefs());
789 JPanel pnl_locPDB = new JPanel(new BorderLayout());
790 pnl_locPDB.add(scrl_localPDB);
792 pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE);
793 pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID);
794 pnl_switchableViews.add(pnl_filter, VIEWS_FILTER);
795 pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB);
797 this.setLayout(new BorderLayout());
798 this.add(pnl_main, java.awt.BorderLayout.NORTH);
799 this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER);
800 // this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
801 statusPanel.setLayout(new GridLayout());
803 JPanel pnl_actionsAndStatus = new JPanel(new BorderLayout());
804 pnl_actionsAndStatus.add(actionsPanel, BorderLayout.CENTER);
805 pnl_actionsAndStatus.add(statusPanel, BorderLayout.SOUTH);
806 statusPanel.add(statusBar, null);
807 this.add(pnl_actionsAndStatus, java.awt.BorderLayout.SOUTH);
809 mainFrame.addInternalFrameListener(
810 new javax.swing.event.InternalFrameAdapter()
813 public void internalFrameClosing(InternalFrameEvent e)
815 closeAction(pnl_filter.getHeight());
818 mainFrame.setVisible(true);
819 mainFrame.setContentPane(this);
820 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
821 Integer x = tempUserPrefs.get("structureChooser.x");
822 Integer y = tempUserPrefs.get("structureChooser.y");
823 if (x != null && y != null)
825 mainFrame.setLocation(x, y);
827 Desktop.addInternalFrame(mainFrame, frameTitle, width, height);
830 protected abstract boolean showPopupFor(int selectedRow, int x, int y);
832 protected void closeAction(int preferredHeight)
834 // System.out.println(">>>>>>>>>> closing internal frame!!!");
835 // System.out.println("width : " + mainFrame.getWidth());
836 // System.out.println("heigh : " + mainFrame.getHeight());
837 // System.out.println("x : " + mainFrame.getX());
838 // System.out.println("y : " + mainFrame.getY());
839 tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth());
840 tempUserPrefs.put("structureChooser.height", preferredHeight);
841 tempUserPrefs.put("structureChooser.x", mainFrame.getX());
842 tempUserPrefs.put("structureChooser.y", mainFrame.getY());
846 public boolean wantedFieldsUpdated()
848 if (previousWantedFields == null)
853 FTSDataColumnI[] currentWantedFields = getFTSDocFieldPrefs()
854 .getStructureSummaryFields().toArray(new FTSDataColumnI[0]);
855 return Arrays.equals(currentWantedFields, previousWantedFields) ? false
862 * Event listener for the 'filter' combo-box and 'invert' check-box
864 public void itemStateChanged(ItemEvent e)
870 * This inner class provides the provides the data model for associate
871 * sequence combo-box - cmb_assSeq
876 public class AssociateSeqOptions
878 private SequenceI sequence;
882 public AssociateSeqOptions(SequenceI seq)
885 this.name = (seq.getName().length() >= 23)
886 ? seq.getName().substring(0, 23)
890 public AssociateSeqOptions(String name, SequenceI seq)
897 public String toString()
902 public String getName()
907 public void setName(String name)
912 public SequenceI getSequence()
917 public void setSequence(SequenceI sequence)
919 this.sequence = sequence;
925 * This inner class holds the Layout and configuration of the panel which
926 * handles association of manually fetched structures to a unique sequence
927 * when more than one sequence selection is made
932 public class AssociateSeqPanel extends JPanel implements ItemListener
934 private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<>();
936 private JLabel lbl_associateSeq = new JLabel();
938 public AssociateSeqPanel()
940 this.setLayout(new FlowLayout());
941 this.add(cmb_assSeq);
942 this.add(lbl_associateSeq);
943 cmb_assSeq.setToolTipText(
944 MessageManager.getString("info.associate_wit_sequence"));
945 cmb_assSeq.addItemListener(this);
948 public void loadCmbAssSeq()
950 populateCmbAssociateSeqOptions(cmb_assSeq, lbl_associateSeq);
953 public JComboBox<AssociateSeqOptions> getCmb_assSeq()
958 public void setCmb_assSeq(JComboBox<AssociateSeqOptions> cmb_assSeq)
960 this.cmb_assSeq = cmb_assSeq;
964 public void itemStateChanged(ItemEvent e)
966 if (e.getStateChange() == ItemEvent.SELECTED)
968 cmbAssSeqStateChanged();
973 public JTable getResultTable()
978 public JComboBox<FilterOption> getCmbFilterOption()
980 return cmb_filterOption;
984 * Custom ListCellRenderer for adding a separator between different categories
985 * of structure chooser filter option drop-down.
990 public abstract class CustomComboSeparatorsRenderer
991 implements ListCellRenderer<Object>
993 private ListCellRenderer<Object> regent;
995 private JPanel separatorPanel = new JPanel(new BorderLayout());
997 private JSeparator jSeparator = new JSeparator();
999 public CustomComboSeparatorsRenderer(
1000 ListCellRenderer<Object> listCellRenderer)
1002 this.regent = listCellRenderer;
1006 public Component getListCellRendererComponent(JList list, Object value,
1007 int index, boolean isSelected, boolean cellHasFocus)
1010 Component comp = regent.getListCellRendererComponent(list, value,
1011 index, isSelected, cellHasFocus);
1013 && addSeparatorAfter(list, (FilterOption) value, index))
1015 separatorPanel.removeAll();
1016 separatorPanel.add(comp, BorderLayout.CENTER);
1017 separatorPanel.add(jSeparator, BorderLayout.SOUTH);
1018 return separatorPanel;
1026 protected abstract boolean addSeparatorAfter(JList list,
1027 FilterOption value, int index);
1030 protected abstract void stateChanged(ItemEvent e);
1032 protected abstract void add_ActionPerformed();
1034 protected abstract void newView_ActionPerformed();
1036 protected abstract void pdbFromFile_actionPerformed();
1038 protected abstract void paeMatrixFile_actionPerformed();
1040 protected abstract void txt_search_ActionPerformed();
1042 protected abstract void populateCmbAssociateSeqOptions(
1043 JComboBox<AssociateSeqOptions> cmb_assSeq,
1044 JLabel lbl_associateSeq);
1046 protected abstract void cmbAssSeqStateChanged();
1048 protected abstract void tabRefresh();
1050 protected abstract void validateSelections();
1052 public JInternalFrame getFrame()
1057 public void setPdbOptionsEnabled(boolean b)
1059 lbl_chooseTempFacType.setEnabled(b);
1060 combo_tempFacAs.setEnabled(b);
1061 btn_paeMatrixFile.setEnabled(b);