X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGStructureChooser.java;h=d9d863a1fe540e664e8232139bd216100cec9e89;hb=c51dbe7933683b64548f5353e67561d2b5e377f7;hp=041fefd8317e1bd6a744778462e561e628911947;hpb=12d4dfa00a5e93ae1de1d8409c6d5ca2bc8af13f;p=jalview.git diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 041fefd..d9d863a 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -28,6 +28,7 @@ import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; import jalview.fts.service.pdb.PDBFTSRestClient; import jalview.gui.AlignmentPanel; import jalview.gui.Desktop; +import jalview.gui.JvSummaryTable; import jalview.gui.JvSwingUtils; import jalview.util.MessageManager; @@ -68,7 +69,6 @@ import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.InternalFrameEvent; -import javax.swing.table.TableColumn; @SuppressWarnings("serial") /** @@ -105,6 +105,8 @@ public abstract class GStructureChooser extends JPanel implements protected JButton btn_pdbFromFile = new JButton(); + protected JButton btn_runPhyre2Prediction = new JButton(); + protected JTextField txt_search = new JTextField(14); private JPanel pnl_actions = new JPanel(); @@ -115,6 +117,10 @@ public abstract class GStructureChooser extends JPanel implements private JPanel pnl_fileChooser = new JPanel(new FlowLayout()); + private JPanel pnl_phyre2Prediction = new JPanel(new FlowLayout()); + + private JPanel pnl_phyre2PredictionBL = new JPanel(new BorderLayout()); + private JPanel pnl_idInputBL = new JPanel(new BorderLayout()); private JPanel pnl_fileChooserBL = new JPanel(new BorderLayout()); @@ -154,6 +160,8 @@ public abstract class GStructureChooser extends JPanel implements protected JLabel lbl_fromFileStatus = new JLabel(errorImage); + protected AssciateSeqPanel phyre2InputAssSeqPanel = new AssciateSeqPanel(); + protected AssciateSeqPanel idInputAssSeqPanel = new AssciateSeqPanel(); protected AssciateSeqPanel fileChooserAssSeqPanel = new AssciateSeqPanel(); @@ -166,6 +174,8 @@ public abstract class GStructureChooser extends JPanel implements protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB"; + protected static final String VIEWS_PHYRE2_PREDICTION = "VIEWS_PHYRE2_PREDICTION"; + protected JTable tbl_local_pdb = new JTable(); protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb); @@ -180,84 +190,19 @@ public abstract class GStructureChooser extends JPanel implements protected static Map tempUserPrefs = new HashMap(); - private JTable tbl_summary = new JTable() - { - private boolean inLayout; - - @Override - public boolean getScrollableTracksViewportWidth() - { - return hasExcessWidth(); - - } - - @Override - public void doLayout() - { - if (hasExcessWidth()) - { - autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS; - } - inLayout = true; - super.doLayout(); - inLayout = false; - autoResizeMode = AUTO_RESIZE_OFF; - } + private JTable tbl_summary = new JvSummaryTable(tempUserPrefs); - protected boolean hasExcessWidth() - { - return getPreferredSize().width < getParent().getWidth(); - } - @Override - public void columnMarginChanged(ChangeEvent e) - { - if (isEditing()) - { - removeEditor(); - } - TableColumn resizingColumn = getTableHeader().getResizingColumn(); - // Need to do this here, before the parent's - // layout manager calls getPreferredSize(). - if (resizingColumn != null && autoResizeMode == AUTO_RESIZE_OFF - && !inLayout) - { - resizingColumn.setPreferredWidth(resizingColumn.getWidth()); - String colHeader = resizingColumn.getHeaderValue().toString(); - tempUserPrefs.put(colHeader, resizingColumn.getWidth()); - } - resizeAndRepaint(); - } + protected JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary); - @Override - public String getToolTipText(MouseEvent evt) - { - String toolTipText = null; - java.awt.Point pnt = evt.getPoint(); - int rowIndex = rowAtPoint(pnt); - int colIndex = columnAtPoint(pnt); + JPanel phyreResultPanel = new JPanel(new BorderLayout()); + + protected static Map tempPrefsForPhyre = new HashMap(); - try - { - if (getValueAt(rowIndex, colIndex) == null) - { - return null; - } - toolTipText = getValueAt(rowIndex, colIndex).toString(); - } catch (Exception e) - { - // e.printStackTrace(); - } - toolTipText = (toolTipText == null ? null - : (toolTipText.length() > 500 ? JvSwingUtils.wrapTooltip( - true, "\"" + toolTipText.subSequence(0, 500) - + "...\"") : JvSwingUtils.wrapTooltip(true, - toolTipText))); - return toolTipText; - } - }; + private JTable tbl_phyre2_summary = new JvSummaryTable(tempPrefsForPhyre); - protected JScrollPane scrl_foundStructures = new JScrollPane(tbl_summary); + protected JScrollPane scrl_phyre2Summary = new JScrollPane( + tbl_phyre2_summary); public GStructureChooser() { @@ -278,6 +223,7 @@ public abstract class GStructureChooser extends JPanel implements * * @throws Exception */ + @SuppressWarnings("unchecked") private void jbInit() throws Exception { Integer width = tempUserPrefs.get("structureChooser.width") == null ? 800 @@ -456,6 +402,90 @@ public abstract class GStructureChooser extends JPanel implements } }); + btn_pdbFromFile.setFont(new java.awt.Font("Verdana", 0, 12)); + tbl_phyre2_summary.setAutoCreateRowSorter(true); + tbl_phyre2_summary.getTableHeader().setReorderingAllowed(false); + + tbl_phyre2_summary.addMouseListener(new MouseAdapter() + { + @Override + public void mouseClicked(MouseEvent e) + { + validateSelections(); + } + + @Override + public void mouseReleased(MouseEvent e) + { + validateSelections(); + } + }); + tbl_phyre2_summary.addKeyListener(new KeyAdapter() + { + @Override + public void keyPressed(KeyEvent evt) + { + validateSelections(); + switch (evt.getKeyCode()) + { + case KeyEvent.VK_ESCAPE: // escape key + mainFrame.dispose(); + break; + case KeyEvent.VK_ENTER: // enter key + if (btn_view.isEnabled()) + { + ok_ActionPerformed(); + } + break; + case KeyEvent.VK_TAB: // tab key + if (evt.isShiftDown()) + { + cmb_filterOption.requestFocus(); + } + else + { + if (btn_view.isEnabled()) + { + btn_view.requestFocus(); + } + else + { + btn_cancel.requestFocus(); + } + } + evt.consume(); + break; + default: + return; + } + } + }); + + String btn_runPhyre2Prediction_title = MessageManager + .getString("label.run_phyre2_prediction"); + btn_runPhyre2Prediction + .setText(btn_runPhyre2Prediction_title + " "); + btn_runPhyre2Prediction + .addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + predict3DModelWithPhyre2(); + } + }); + btn_runPhyre2Prediction.addKeyListener(new KeyAdapter() + { + @Override + public void keyPressed(KeyEvent evt) + { + if (evt.getKeyCode() == KeyEvent.VK_ENTER) + { + predict3DModelWithPhyre2(); + } + } + }); + scrl_foundStructures.setPreferredSize(new Dimension(width, height)); scrl_localPDB.setPreferredSize(new Dimension(width, height)); @@ -522,6 +552,17 @@ public abstract class GStructureChooser extends JPanel implements pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.NORTH); pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER); + scrl_phyre2Summary.setPreferredSize(new Dimension(width, height)); + scrl_phyre2Summary + .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + + phyreResultPanel.add(pnl_phyre2Prediction, BorderLayout.NORTH); + phyreResultPanel.add(scrl_phyre2Summary, BorderLayout.CENTER); + + pnl_phyre2Prediction.add(btn_runPhyre2Prediction); + pnl_phyre2PredictionBL.add(phyre2InputAssSeqPanel, BorderLayout.NORTH); + pnl_phyre2PredictionBL.add(phyreResultPanel, BorderLayout.CENTER); + pnl_idInput.add(txt_search); pnl_idInput.add(lbl_pdbManualFetchStatus); pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH); @@ -577,6 +618,8 @@ public abstract class GStructureChooser extends JPanel implements pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID); pnl_switchableViews.add(pnl_filter, VIEWS_FILTER); pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB); + pnl_switchableViews + .add(pnl_phyre2PredictionBL, VIEWS_PHYRE2_PREDICTION); this.setLayout(mainLayout); this.add(pnl_main, java.awt.BorderLayout.NORTH); @@ -611,13 +654,9 @@ public abstract class GStructureChooser extends JPanel implements protected void closeAction(int preferredHeight) { - // System.out.println(">>>>>>>>>> closing internal frame!!!"); - // System.out.println("width : " + mainFrame.getWidth()); - // System.out.println("heigh : " + mainFrame.getHeight()); - // System.out.println("x : " + mainFrame.getX()); - // System.out.println("y : " + mainFrame.getY()); tempUserPrefs.put("structureChooser.width", pnl_filter.getWidth()); - tempUserPrefs.put("structureChooser.height", preferredHeight); + tempUserPrefs.put("structureChooser.height", + pnl_filter.getHeight() - 76); tempUserPrefs.put("structureChooser.x", mainFrame.getX()); tempUserPrefs.put("structureChooser.y", mainFrame.getY()); mainFrame.dispose(); @@ -662,6 +701,7 @@ public abstract class GStructureChooser extends JPanel implements private boolean addSeparatorAfter; + /** * Model for structure filter option * @@ -675,6 +715,7 @@ public abstract class GStructureChooser extends JPanel implements * - if true, a horizontal separator is rendered immediately after * this filter option, otherwise */ + public FilterOption(String name, String value, String view, boolean addSeparatorAfter) { @@ -844,6 +885,7 @@ public abstract class GStructureChooser extends JPanel implements return cmb_filterOption; } + /** * Custom ListCellRenderer for adding a separator between different categories * of structure chooser filter option drop-down. @@ -851,6 +893,13 @@ public abstract class GStructureChooser extends JPanel implements * @author tcnofoegbu * */ + + public JTable getPhyreResultTable() + { + return tbl_phyre2_summary; + } + + public abstract class CustomComboSeparatorsRenderer implements ListCellRenderer { @@ -908,4 +957,7 @@ public abstract class GStructureChooser extends JPanel implements public abstract void tabRefresh(); public abstract void validateSelections(); + + public abstract void predict3DModelWithPhyre2(); + } \ No newline at end of file