2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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 jalview.gui.Desktop;
25 import jalview.util.MessageManager;
26 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
27 import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
29 import java.awt.BorderLayout;
30 import java.awt.Dimension;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
34 import javax.swing.JButton;
35 import javax.swing.JComboBox;
36 import javax.swing.JFrame;
37 import javax.swing.JInternalFrame;
38 import javax.swing.JList;
39 import javax.swing.JPanel;
40 import javax.swing.JScrollPane;
41 import javax.swing.JTextField;
42 import javax.swing.ListSelectionModel;
43 import javax.swing.event.DocumentEvent;
44 import javax.swing.event.DocumentListener;
47 * GUI layout for PDB Fetch Panel
52 @SuppressWarnings("serial")
53 public abstract class GPDBSearchPanel extends JPanel
55 protected String frameTitle = MessageManager
56 .getString("label.pdb_sequence_getcher");
58 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
60 protected JComboBox<PDBDocField> cmb_searchTarget = new JComboBox<PDBDocField>();
62 protected JButton btn_ok = new JButton();
64 protected JButton btn_back = new JButton();
66 protected JButton btn_cancel = new JButton();
68 protected JTextField txt_search = new JTextField(20);
70 protected JList<PDBResponseSummary> lst_searchResult = new JList<PDBResponseSummary>();
72 protected JScrollPane scrl_searchResult = new JScrollPane(
75 private JPanel pnl_actions = new JPanel();
77 private JPanel pnl_results = new JPanel();
79 private JPanel pnl_inputs = new JPanel();
81 private BorderLayout mainLayout = new BorderLayout();
83 public GPDBSearchPanel()
88 mainFrame.invalidate();
97 * Initializes the GUI default properties
101 private void jbInit() throws Exception
103 btn_back.setFont(new java.awt.Font("Verdana", 0, 12));
104 btn_back.setText(MessageManager.getString("action.back"));
105 btn_back.addActionListener(new java.awt.event.ActionListener()
107 public void actionPerformed(ActionEvent e)
109 btn_back_ActionPerformed();
112 btn_ok.setFont(new java.awt.Font("Verdana", 0, 12));
113 btn_ok.setText(MessageManager.getString("action.ok"));
114 btn_ok.addActionListener(new java.awt.event.ActionListener()
116 public void actionPerformed(ActionEvent e)
118 btn_ok_ActionPerformed();
121 btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
122 btn_cancel.setText(MessageManager.getString("action.cancel"));
123 btn_cancel.addActionListener(new java.awt.event.ActionListener()
125 public void actionPerformed(ActionEvent e)
127 btn_cancel_ActionPerformed();
130 pnl_actions.add(btn_back);
131 pnl_actions.add(btn_ok);
132 pnl_actions.add(btn_cancel);
135 .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
136 lst_searchResult.setLayoutOrientation(JList.VERTICAL);
137 lst_searchResult.setVisibleRowCount(-1);
138 scrl_searchResult.setPreferredSize(new Dimension(500, 300));
140 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
141 pnl_results.add(scrl_searchResult);
143 cmb_searchTarget.setFont(new java.awt.Font("Verdana", 0, 12));
144 cmb_searchTarget.addActionListener(new ActionListener()
147 public void actionPerformed(ActionEvent e)
149 txt_search_ActionPerformed();
153 populateCmbSearchTargetOptions();
155 txt_search.setFont(new java.awt.Font("Verdana", 0, 12));
156 txt_search.getDocument().addDocumentListener(new DocumentListener()
159 public void insertUpdate(DocumentEvent e)
161 txt_search_ActionPerformed();
165 public void removeUpdate(DocumentEvent e)
167 txt_search_ActionPerformed();
171 public void changedUpdate(DocumentEvent e)
173 txt_search_ActionPerformed();
177 pnl_inputs.add(cmb_searchTarget);
178 pnl_inputs.add(txt_search);
180 this.setLayout(mainLayout);
181 this.add(pnl_inputs, java.awt.BorderLayout.NORTH);
182 this.add(pnl_results, java.awt.BorderLayout.CENTER);
183 this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
184 mainFrame.setVisible(true);
185 mainFrame.setContentPane(this);
186 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
187 Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
190 public JComboBox<PDBDocField> getCmbSearchTarget()
192 return cmb_searchTarget;
195 public JTextField getTxtSearch()
200 public JInternalFrame getMainFrame()
205 public abstract void txt_search_ActionPerformed();
207 public abstract void btn_ok_ActionPerformed();
209 public abstract void btn_back_ActionPerformed();
211 public abstract void btn_cancel_ActionPerformed();
213 public abstract void populateCmbSearchTargetOptions();