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.ImageIcon;
37 import javax.swing.JButton;
38 import javax.swing.JComboBox;
39 import javax.swing.JFrame;
40 import javax.swing.JInternalFrame;
41 import javax.swing.JLabel;
42 import javax.swing.JPanel;
43 import javax.swing.JScrollPane;
44 import javax.swing.JTabbedPane;
45 import javax.swing.JTable;
46 import javax.swing.JTextField;
47 import javax.swing.event.ChangeEvent;
48 import javax.swing.event.ChangeListener;
49 import javax.swing.event.DocumentEvent;
50 import javax.swing.event.DocumentListener;
53 * GUI layout for PDB Fetch Panel
58 @SuppressWarnings("serial")
59 public abstract class GPDBSearchPanel extends JPanel
61 protected String frameTitle = MessageManager
62 .getString("label.pdb_sequence_getcher");
64 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
66 protected JComboBox<PDBDocField> cmb_searchTarget = new JComboBox<PDBDocField>();
68 protected JButton btn_ok = new JButton();
70 protected JButton btn_back = new JButton();
72 protected JButton btn_cancel = new JButton();
74 protected JTextField txt_search = new JTextField(20);
76 protected JTable tbl_summary = new JTable();
78 protected StringBuilder errorWarning = new StringBuilder();
80 protected JScrollPane scrl_searchResult = new JScrollPane(
83 protected ImageIcon warningImage = new ImageIcon(getClass().getResource(
84 "/images/warning.gif"));
86 protected JLabel lbl_warning = new JLabel(warningImage);
88 private JTabbedPane tabbedPane = new JTabbedPane();
90 private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
91 PreferenceSource.SEARCH_SUMMARY);
93 private JPanel pnl_actions = new JPanel();
95 private JPanel pnl_results = new JPanel();
97 private JPanel pnl_inputs = new JPanel();
99 private BorderLayout mainLayout = new BorderLayout();
101 public GPDBSearchPanel()
106 mainFrame.invalidate();
108 } catch (Exception e)
115 * Initializes the GUI default properties
119 private void jbInit() throws Exception
121 lbl_warning.setVisible(false);
122 lbl_warning.setFont(new java.awt.Font("Verdana", 0, 12));
124 tbl_summary.setAutoCreateRowSorter(true);
125 tbl_summary.addMouseListener(new MouseAdapter()
127 public void mouseClicked(MouseEvent e)
129 if (tbl_summary.getSelectedRows().length > 0)
131 btn_ok.setEnabled(true);
135 btn_ok.setEnabled(false);
140 btn_back.setFont(new java.awt.Font("Verdana", 0, 12));
141 btn_back.setText(MessageManager.getString("action.back"));
142 btn_back.addActionListener(new java.awt.event.ActionListener()
144 public void actionPerformed(ActionEvent e)
146 btn_back_ActionPerformed();
150 btn_ok.setEnabled(false);
151 btn_ok.setFont(new java.awt.Font("Verdana", 0, 12));
152 btn_ok.setText(MessageManager.getString("action.ok"));
153 btn_ok.addActionListener(new java.awt.event.ActionListener()
155 public void actionPerformed(ActionEvent e)
157 btn_ok_ActionPerformed();
160 btn_cancel.setFont(new java.awt.Font("Verdana", 0, 12));
161 btn_cancel.setText(MessageManager.getString("action.cancel"));
162 btn_cancel.addActionListener(new java.awt.event.ActionListener()
164 public void actionPerformed(ActionEvent e)
166 btn_cancel_ActionPerformed();
171 scrl_searchResult.setPreferredSize(new Dimension(500, 300));
173 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
175 cmb_searchTarget.setFont(new java.awt.Font("Verdana", 0, 12));
176 cmb_searchTarget.addActionListener(new ActionListener()
179 public void actionPerformed(ActionEvent e)
181 txt_search_ActionPerformed();
185 populateCmbSearchTargetOptions();
186 txt_search.setToolTipText(MessageManager
187 .getString("label.separate_multiple_accession_ids"));
188 txt_search.setFont(new java.awt.Font("Verdana", 0, 12));
189 txt_search.getDocument().addDocumentListener(new DocumentListener()
192 public void insertUpdate(DocumentEvent e)
194 txt_search_ActionPerformed();
198 public void removeUpdate(DocumentEvent e)
200 txt_search_ActionPerformed();
204 public void changedUpdate(DocumentEvent e)
206 txt_search_ActionPerformed();
210 final String searchTabTitle = MessageManager
211 .getString("label.search_result");
212 ChangeListener changeListener = new ChangeListener()
214 public void stateChanged(ChangeEvent changeEvent)
216 JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
218 int index = sourceTabbedPane.getSelectedIndex();
219 if (sourceTabbedPane.getTitleAt(index).equals(searchTabTitle))
221 txt_search_ActionPerformed();
225 tabbedPane.addChangeListener(changeListener);
226 tabbedPane.setPreferredSize(new Dimension(500, 300));
227 tabbedPane.add(searchTabTitle, scrl_searchResult);
229 MessageManager.getString("label.configure_displayed_columns"),
232 pnl_actions.add(btn_back);
233 pnl_actions.add(btn_ok);
234 pnl_actions.add(btn_cancel);
236 pnl_results.add(tabbedPane);
237 pnl_inputs.add(cmb_searchTarget);
238 pnl_inputs.add(txt_search);
239 pnl_inputs.add(lbl_warning);
241 this.setLayout(mainLayout);
242 this.add(pnl_inputs, java.awt.BorderLayout.NORTH);
243 this.add(pnl_results, java.awt.BorderLayout.CENTER);
244 this.add(pnl_actions, java.awt.BorderLayout.SOUTH);
245 mainFrame.setVisible(true);
246 mainFrame.setContentPane(this);
247 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
248 Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
251 public JComboBox<PDBDocField> getCmbSearchTarget()
253 return cmb_searchTarget;
256 public JTextField getTxtSearch()
261 public JInternalFrame getMainFrame()
266 public abstract void txt_search_ActionPerformed();
268 public abstract void btn_ok_ActionPerformed();
270 public abstract void btn_back_ActionPerformed();
272 public abstract void btn_cancel_ActionPerformed();
274 public abstract void populateCmbSearchTargetOptions();