3 import jalview.gui.AlignmentPanel;
4 import jalview.gui.Desktop;
5 import jalview.util.MessageManager;
6 import jalview.ws.uimodel.PDBSearchResponse.PDBResponseSummary;
8 import java.awt.BorderLayout;
9 import java.awt.CardLayout;
10 import java.awt.Dimension;
11 import java.awt.FlowLayout;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.ItemEvent;
14 import java.awt.event.ItemListener;
16 import javax.swing.JButton;
17 import javax.swing.JCheckBox;
18 import javax.swing.JComboBox;
19 import javax.swing.JFrame;
20 import javax.swing.JInternalFrame;
21 import javax.swing.JLabel;
22 import javax.swing.JList;
23 import javax.swing.JPanel;
24 import javax.swing.JScrollPane;
25 import javax.swing.JTextField;
26 import javax.swing.ListSelectionModel;
28 @SuppressWarnings("serial")
29 public abstract class GStructureChooser extends JPanel implements
32 protected String frameTitle = "Structure Chooser";
34 protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
38 protected JComboBox<FilterOptions> filterOptionsComboBox = new JComboBox<FilterOptions>();
40 protected AlignmentPanel ap;
42 protected JLabel resultLabel = new JLabel("View : ");
44 protected JButton ok = new JButton();
46 protected JButton cancel = new JButton();
48 protected JButton pdbFromFile = new JButton();
50 protected JTextField search = new JTextField(16);
52 protected JPanel actionPanel = new JPanel();
54 protected JPanel filterPanel = new JPanel();
56 protected JPanel idInputPanel = new JPanel();
58 protected JPanel fileChooserPanel = new JPanel();
60 protected JPanel switchableViewsPanel = new JPanel(new CardLayout());
62 protected CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel
65 protected BorderLayout mainLayout = new BorderLayout();
67 protected BorderLayout idInputPanelLayout = new BorderLayout();
69 protected BorderLayout fileChooserPanelLayout = new BorderLayout();
71 protected JCheckBox rememberSettings = new JCheckBox("Don't ask me again");
74 protected static final String VIEWS_FILTER = "VIEWS_FILTER";
76 protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE";
78 protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
80 protected JList<PDBResponseSummary> jListFoundStructures = new JList<PDBResponseSummary>();
82 protected JScrollPane foundStructuresScroller = new JScrollPane(
83 jListFoundStructures);
85 public GStructureChooser()
90 mainFrame.invalidate();
98 private void jbInit() throws Exception
101 ok.setFont(new java.awt.Font("Verdana", 0, 12));
102 ok.setText(MessageManager.getString("action.ok"));
103 ok.addActionListener(new java.awt.event.ActionListener()
105 public void actionPerformed(ActionEvent e)
107 ok_ActionPerformed();
110 cancel.setFont(new java.awt.Font("Verdana", 0, 12));
111 cancel.setText(MessageManager.getString("action.cancel"));
112 cancel.addActionListener(new java.awt.event.ActionListener()
114 public void actionPerformed(ActionEvent e)
120 pdbFromFile.setFont(new java.awt.Font("Verdana", 0, 12));
121 pdbFromFile.setText(" Select PDB File ");
122 pdbFromFile.addActionListener(new java.awt.event.ActionListener()
124 public void actionPerformed(ActionEvent e)
126 pdbFromFile_actionPerformed();
131 .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
132 jListFoundStructures.setLayoutOrientation(JList.VERTICAL);
133 jListFoundStructures.setVisibleRowCount(-1);
134 foundStructuresScroller.setPreferredSize(new Dimension(500, 300));
135 foundStructuresScroller
136 .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
138 actionPanel.add(rememberSettings);
140 actionPanel.add(cancel);
142 filterOptionsComboBox.addItemListener(this);
144 filterPanel.add(resultLabel);
145 filterPanel.add(filterOptionsComboBox);
147 idInputPanel.setLayout(new FlowLayout());
148 idInputPanel.add(search);
151 fileChooserPanel.setLayout(new FlowLayout());
152 fileChooserPanel.add(pdbFromFile);
154 switchableViewsPanel.add(fileChooserPanel, VIEWS_FROM_FILE);
155 switchableViewsPanel.add(idInputPanel, VIEWS_ENTER_ID);
156 switchableViewsPanel.add(foundStructuresScroller, VIEWS_FILTER);
159 this.setLayout(mainLayout);
160 this.add(filterPanel, java.awt.BorderLayout.NORTH);
161 this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER);
162 this.add(actionPanel, java.awt.BorderLayout.SOUTH);
164 mainFrame.setVisible(true);
165 mainFrame.setContentPane(this);
166 mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
167 Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
171 public void itemStateChanged(ItemEvent e)
176 public class FilterOptions
180 private String value;
184 public FilterOptions(String name, String value, String view)
191 public String getName()
196 public void setName(String name)
201 public String getValue()
206 public void setValue(String value)
211 public String getView()
216 public void setView(String view)
221 public String toString()
227 protected abstract void stateChanged();
229 protected abstract void updateCurrentView();
231 protected abstract void ok_ActionPerformed();
233 protected abstract void populateFilterOptions();
235 protected abstract void pdbFromFile_actionPerformed();