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;
34 import javax.swing.JButton;
35 import javax.swing.JComboBox;
36 import javax.swing.JFrame;
37 import javax.swing.JInternalFrame;
38 import javax.swing.JPanel;
39 import javax.swing.JScrollPane;
40 import javax.swing.JTabbedPane;
41 import javax.swing.JTable;
42 import javax.swing.JTextField;
43 import javax.swing.event.ChangeEvent;
44 import javax.swing.event.ChangeListener;
45 import javax.swing.event.DocumentEvent;
46 import javax.swing.event.DocumentListener;
49 * GUI layout for PDB Fetch Panel
54 @SuppressWarnings("serial")
55 public abstract class GPDBSearchPanel extends JPanel
57 protected String frameTitle = MessageManager
58 .getString("label.pdb_sequence_getcher");
60 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
62 protected JComboBox<PDBDocField> cmb_searchTarget = new JComboBox<PDBDocField>();
64 protected JButton btn_ok = new JButton();
66 protected JButton btn_back = new JButton();
68 protected JButton btn_cancel = new JButton();
70 protected JTextField txt_search = new JTextField(20);
72 protected JTable tbl_summary = new JTable();
74 protected JScrollPane scrl_searchResult = new JScrollPane(
77 private JTabbedPane tabbedPane = new JTabbedPane();
79 private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
80 PreferenceSource.SEARCH_SUMMARY);
82 private JPanel pnl_actions = new JPanel();
84 private JPanel pnl_results = new JPanel();
86 private JPanel pnl_inputs = new JPanel();
88 private BorderLayout mainLayout = new BorderLayout();
90 public GPDBSearchPanel()
95 mainFrame.invalidate();
104 * Initializes the GUI default properties
108 private void jbInit() throws Exception
110 tbl_summary.setAutoCreateRowSorter(true);
111 btn_back.setFont(new java.awt.Font("Verdana", 0, 12));
112 btn_back.setText(MessageManager.getString("action.back"));
113 btn_back.addActionListener(new java.awt.event.ActionListener()
115 public void actionPerformed(ActionEvent e)
117 btn_back_ActionPerformed();
120 btn_ok.setFont(new java.awt.Font("Verdana", 0, 12));
121 btn_ok.setText(MessageManager.getString("action.ok"));
122 btn_ok.addActionListener(new java.awt.event.ActionListener()
124 public void actionPerformed(ActionEvent e)
126 btn_ok_ActionPerformed();
129 btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
130 btn_cancel.setText(MessageManager.getString("action.cancel"));
131 btn_cancel.addActionListener(new java.awt.event.ActionListener()
133 public void actionPerformed(ActionEvent e)
135 btn_cancel_ActionPerformed();
139 scrl_searchResult.setPreferredSize(new Dimension(500, 300));
141 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
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 final String searchTabTitle = MessageManager
178 .getString("label.search_result");
179 ChangeListener changeListener = new ChangeListener()
181 public void stateChanged(ChangeEvent changeEvent)
183 JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
185 int index = sourceTabbedPane.getSelectedIndex();
186 if (sourceTabbedPane.getTitleAt(index).equals(searchTabTitle))
188 txt_search_ActionPerformed();
192 tabbedPane.addChangeListener(changeListener);
193 tabbedPane.setPreferredSize(new Dimension(500, 300));
194 tabbedPane.add(searchTabTitle, scrl_searchResult);
196 MessageManager.getString("label.configure_displayed_columns"),
199 pnl_actions.add(btn_back);
200 pnl_actions.add(btn_ok);
201 pnl_actions.add(btn_cancel);
203 pnl_results.add(tabbedPane);
204 pnl_inputs.add(cmb_searchTarget);
205 pnl_inputs.add(txt_search);
207 this.setLayout(mainLayout);
208 this.add(pnl_inputs, java.awt.BorderLayout.NORTH);
209 this.add(pnl_results, java.awt.BorderLayout.CENTER);
210 this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
211 mainFrame.setVisible(true);
212 mainFrame.setContentPane(this);
213 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
214 Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
217 public JComboBox<PDBDocField> getCmbSearchTarget()
219 return cmb_searchTarget;
222 public JTextField getTxtSearch()
227 public JInternalFrame getMainFrame()
232 public abstract void txt_search_ActionPerformed();
234 public abstract void btn_ok_ActionPerformed();
236 public abstract void btn_back_ActionPerformed();
238 public abstract void btn_cancel_ActionPerformed();
240 public abstract void populateCmbSearchTargetOptions();