/* * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.jbgui; import jalview.gui.Desktop; import jalview.util.MessageManager; import jalview.ws.dbsources.PDBRestClient.PDBDocField; import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; /** * GUI layout for PDB Fetch Panel * * @author tcnofoegbu * */ @SuppressWarnings("serial") public abstract class GPDBSearchPanel extends JPanel { protected String frameTitle = MessageManager .getString("label.pdb_sequence_getcher"); protected JInternalFrame mainFrame = new JInternalFrame(frameTitle); protected JComboBox cmb_searchTarget = new JComboBox(); protected JButton btn_ok = new JButton(); protected JButton btn_back = new JButton(); protected JButton btn_cancel = new JButton(); protected JTextField txt_search = new JTextField(20); protected JList lst_searchResult = new JList(); protected JScrollPane scrl_searchResult = new JScrollPane( lst_searchResult); private JPanel pnl_actions = new JPanel(); private JPanel pnl_results = new JPanel(); private JPanel pnl_inputs = new JPanel(); private BorderLayout mainLayout = new BorderLayout(); public GPDBSearchPanel() { try { jbInit(); mainFrame.invalidate(); mainFrame.pack(); } catch (Exception e) { e.printStackTrace(); } } /** * Initializes the GUI default properties * * @throws Exception */ private void jbInit() throws Exception { btn_back.setFont(new java.awt.Font("Verdana", 0, 12)); btn_back.setText(MessageManager.getString("action.back")); btn_back.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btn_back_ActionPerformed(); } }); btn_ok.setFont(new java.awt.Font("Verdana", 0, 12)); btn_ok.setText(MessageManager.getString("action.ok")); btn_ok.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btn_ok_ActionPerformed(); } }); btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12)); btn_cancel.setText(MessageManager.getString("action.cancel")); btn_cancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btn_cancel_ActionPerformed(); } }); pnl_actions.add(btn_back); pnl_actions.add(btn_ok); pnl_actions.add(btn_cancel); lst_searchResult .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); lst_searchResult.setLayoutOrientation(JList.VERTICAL); lst_searchResult.setVisibleRowCount(-1); scrl_searchResult.setPreferredSize(new Dimension(500, 300)); scrl_searchResult .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); pnl_results.add(scrl_searchResult); cmb_searchTarget.setFont(new java.awt.Font("Verdana", 0, 12)); cmb_searchTarget.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { txt_search_ActionPerformed(); } }); populateCmbSearchTargetOptions(); txt_search.setFont(new java.awt.Font("Verdana", 0, 12)); txt_search.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { txt_search_ActionPerformed(); } @Override public void removeUpdate(DocumentEvent e) { txt_search_ActionPerformed(); } @Override public void changedUpdate(DocumentEvent e) { txt_search_ActionPerformed(); } }); pnl_inputs.add(cmb_searchTarget); pnl_inputs.add(txt_search); this.setLayout(mainLayout); this.add(pnl_inputs, java.awt.BorderLayout.NORTH); this.add(pnl_results, java.awt.BorderLayout.CENTER); this.add(pnl_actions, java.awt.BorderLayout.SOUTH); mainFrame.setVisible(true); mainFrame.setContentPane(this); mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400); } public JComboBox getCmbSearchTarget() { return cmb_searchTarget; } public JTextField getTxtSearch() { return txt_search; } public JInternalFrame getMainFrame() { return mainFrame; } public abstract void txt_search_ActionPerformed(); public abstract void btn_ok_ActionPerformed(); public abstract void btn_back_ActionPerformed(); public abstract void btn_cancel_ActionPerformed(); public abstract void populateCmbSearchTargetOptions(); }