3 import jalview.gui.AnnotationColumnChooser;
4 import jalview.gui.JvSwingUtils;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
10 import javax.swing.JCheckBox;
11 import javax.swing.JPanel;
12 import javax.swing.JTextField;
13 import javax.swing.border.TitledBorder;
14 import javax.swing.event.DocumentEvent;
15 import javax.swing.event.DocumentListener;
17 @SuppressWarnings("serial")
18 public class SearchPanel extends JPanel
21 private AnnotationColumnChooser aColChooser;
23 private JCheckBox displayName = new JCheckBox();
25 private JCheckBox description = new JCheckBox();
27 private JTextField searchBox = new JTextField(10);
29 private JCheckBox structuresFilter = new JCheckBox();
31 public SearchPanel(AnnotationColumnChooser aColChooser)
34 this.aColChooser = aColChooser;
35 this.setBorder(new TitledBorder("Search Filter"));
36 this.setBackground(Color.white);
37 this.setFont(JvSwingUtils.getLabelFont());
40 getSearchBox().setBackground(Color.white);
41 getSearchBox().setFont(JvSwingUtils.getLabelFont());
42 getSearchBox().getDocument().addDocumentListener(new DocumentListener()
45 public void insertUpdate(DocumentEvent e)
51 public void removeUpdate(DocumentEvent e)
57 public void changedUpdate(DocumentEvent e)
63 getDisplayName().setBackground(Color.white);
64 getDisplayName().setFont(JvSwingUtils.getLabelFont());
65 getDisplayName().setText("Display Name");
66 getDisplayName().setEnabled(false);
67 getDisplayName().addActionListener(new ActionListener()
70 public void actionPerformed(ActionEvent actionEvent)
72 displayNameCheckboxAction();
76 getDescription().setBackground(Color.white);
77 getDescription().setFont(JvSwingUtils.getLabelFont());
78 getDescription().setText("Description");
79 getDescription().setEnabled(false);
80 getDescription().addActionListener(new ActionListener()
83 public void actionPerformed(ActionEvent actionEvent)
85 discriptionCheckboxAction();
90 this.add(getSearchBox());
91 this.add(getDisplayName());
92 this.add(getDescription());
95 public boolean isDescriptionChecked()
97 return getDescription().isSelected();
100 public boolean isDisplayNameChecked()
102 return getDisplayName().isSelected();
105 public String getSearchString()
107 return getSearchBox().getText();
110 public void displayNameCheckboxAction()
112 aColChooser.setCurrentSearchPanel(this);
113 aColChooser.updateView();
116 public void discriptionCheckboxAction()
118 aColChooser.setCurrentSearchPanel(this);
119 aColChooser.updateView();
122 public void searchStringAction()
124 aColChooser.setCurrentSearchPanel(this);
125 aColChooser.updateView();
128 public JCheckBox getDisplayName()
133 public void setDisplayName(JCheckBox displayName)
135 this.displayName = displayName;
138 public JCheckBox getDescription()
143 public void setDescription(JCheckBox description)
145 this.description = description;
148 public JTextField getSearchBox()
153 public void setSearchBox(JTextField searchBox)
155 this.searchBox = searchBox;
158 public JCheckBox getStructuresFilter()
160 return structuresFilter;
163 public void setStructuresFilter(JCheckBox structuresFilter)
165 this.structuresFilter = structuresFilter;
168 public void syncState()
170 SearchPanel sp = aColChooser.getCurrentSearchPanel();
173 description.setEnabled(sp.getDescription().isEnabled());
174 description.setSelected(sp.getDescription().isSelected());
176 displayName.setEnabled(sp.getDisplayName().isEnabled());
177 displayName.setSelected(sp.getDisplayName().isSelected());
179 searchBox.setText(sp.getSearchBox().getText());