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.jbgui.PDBDocFieldPreferences.PreferenceSource;
26 import jalview.util.MessageManager;
27 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
29 import java.awt.BorderLayout;
30 import java.awt.Dimension;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.awt.event.MouseAdapter;
34 import java.awt.event.MouseEvent;
36 import javax.swing.JButton;
37 import javax.swing.JComboBox;
38 import javax.swing.JFrame;
39 import javax.swing.JInternalFrame;
40 import javax.swing.JPanel;
41 import javax.swing.JScrollPane;
42 import javax.swing.JTabbedPane;
43 import javax.swing.JTable;
44 import javax.swing.JTextField;
45 import javax.swing.event.ChangeEvent;
46 import javax.swing.event.ChangeListener;
47 import javax.swing.event.DocumentEvent;
48 import javax.swing.event.DocumentListener;
51 * GUI layout for PDB Fetch Panel
56 @SuppressWarnings("serial")
57 public abstract class GPDBSearchPanel extends JPanel
59 protected String frameTitle = MessageManager
60 .getString("label.pdb_sequence_getcher");
62 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
64 protected JComboBox<PDBDocField> cmb_searchTarget = new JComboBox<PDBDocField>();
66 protected JButton btn_ok = new JButton();
68 protected JButton btn_back = new JButton();
70 protected JButton btn_cancel = new JButton();
72 protected JTextField txt_search = new JTextField(20);
74 protected JTable tbl_summary = new JTable();
76 protected JScrollPane scrl_searchResult = new JScrollPane(
79 private JTabbedPane tabbedPane = new JTabbedPane();
81 private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
82 PreferenceSource.SEARCH_SUMMARY);
84 private JPanel pnl_actions = new JPanel();
86 private JPanel pnl_results = new JPanel();
88 private JPanel pnl_inputs = new JPanel();
90 private BorderLayout mainLayout = new BorderLayout();
92 public GPDBSearchPanel()
97 mainFrame.invalidate();
106 * Initializes the GUI default properties
110 private void jbInit() throws Exception
112 tbl_summary.setAutoCreateRowSorter(true);
113 tbl_summary.addMouseListener(new MouseAdapter()
115 public void mouseClicked(MouseEvent e)
117 if (tbl_summary.getSelectedRows().length > 0)
119 btn_ok.setEnabled(true);
123 btn_ok.setEnabled(false);
128 btn_back.setFont(new java.awt.Font("Verdana", 0, 12));
129 btn_back.setText(MessageManager.getString("action.back"));
130 btn_back.addActionListener(new java.awt.event.ActionListener()
132 public void actionPerformed(ActionEvent e)
134 btn_back_ActionPerformed();
138 btn_ok.setEnabled(false);
139 btn_ok.setFont(new java.awt.Font("Verdana", 0, 12));
140 btn_ok.setText(MessageManager.getString("action.ok"));
141 btn_ok.addActionListener(new java.awt.event.ActionListener()
143 public void actionPerformed(ActionEvent e)
145 btn_ok_ActionPerformed();
148 btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
149 btn_cancel.setText(MessageManager.getString("action.cancel"));
150 btn_cancel.addActionListener(new java.awt.event.ActionListener()
152 public void actionPerformed(ActionEvent e)
154 btn_cancel_ActionPerformed();
159 scrl_searchResult.setPreferredSize(new Dimension(500, 300));
161 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
163 cmb_searchTarget.setFont(new java.awt.Font("Verdana", 0, 12));
164 cmb_searchTarget.addActionListener(new ActionListener()
167 public void actionPerformed(ActionEvent e)
169 txt_search_ActionPerformed();
173 populateCmbSearchTargetOptions();
175 txt_search.setFont(new java.awt.Font("Verdana", 0, 12));
176 txt_search.getDocument().addDocumentListener(new DocumentListener()
179 public void insertUpdate(DocumentEvent e)
181 txt_search_ActionPerformed();
185 public void removeUpdate(DocumentEvent e)
187 txt_search_ActionPerformed();
191 public void changedUpdate(DocumentEvent e)
193 txt_search_ActionPerformed();
197 final String searchTabTitle = MessageManager
198 .getString("label.search_result");
199 ChangeListener changeListener = new ChangeListener()
201 public void stateChanged(ChangeEvent changeEvent)
203 JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
205 int index = sourceTabbedPane.getSelectedIndex();
206 if (sourceTabbedPane.getTitleAt(index).equals(searchTabTitle))
208 txt_search_ActionPerformed();
212 tabbedPane.addChangeListener(changeListener);
213 tabbedPane.setPreferredSize(new Dimension(500, 300));
214 tabbedPane.add(searchTabTitle, scrl_searchResult);
216 MessageManager.getString("label.configure_displayed_columns"),
219 pnl_actions.add(btn_back);
220 pnl_actions.add(btn_ok);
221 pnl_actions.add(btn_cancel);
223 pnl_results.add(tabbedPane);
224 pnl_inputs.add(cmb_searchTarget);
225 pnl_inputs.add(txt_search);
227 this.setLayout(mainLayout);
228 this.add(pnl_inputs, java.awt.BorderLayout.NORTH);
229 this.add(pnl_results, java.awt.BorderLayout.CENTER);
230 this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
231 mainFrame.setVisible(true);
232 mainFrame.setContentPane(this);
233 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
234 Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
237 public JComboBox<PDBDocField> getCmbSearchTarget()
239 return cmb_searchTarget;
242 public JTextField getTxtSearch()
247 public JInternalFrame getMainFrame()
252 public abstract void txt_search_ActionPerformed();
254 public abstract void btn_ok_ActionPerformed();
256 public abstract void btn_back_ActionPerformed();
258 public abstract void btn_cancel_ActionPerformed();
260 public abstract void populateCmbSearchTargetOptions();