Merge remote-tracking branch 'origin/develop' into
[jalview.git] / src / jalview / gui / AnnotationColumnChooser.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21
22 package jalview.gui;
23
24 import jalview.datamodel.AlignmentAnnotation;
25 import jalview.datamodel.HiddenColumns;
26 import jalview.schemes.AnnotationColourGradient;
27 import jalview.util.MessageManager;
28 import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
29
30 import java.awt.BorderLayout;
31 import java.awt.CardLayout;
32 import java.awt.Color;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35 import java.awt.event.ItemEvent;
36 import java.awt.event.ItemListener;
37 import java.util.Iterator;
38
39 import javax.swing.ButtonGroup;
40 import javax.swing.JCheckBox;
41 import javax.swing.JComboBox;
42 import javax.swing.JInternalFrame;
43 import javax.swing.JLayeredPane;
44 import javax.swing.JPanel;
45 import javax.swing.JRadioButton;
46 import javax.swing.JTextField;
47 import javax.swing.border.TitledBorder;
48 import javax.swing.event.DocumentEvent;
49 import javax.swing.event.DocumentListener;
50
51 import net.miginfocom.swing.MigLayout;
52
53 @SuppressWarnings("serial")
54 public class AnnotationColumnChooser extends AnnotationRowFilter implements
55         ItemListener
56 {
57   private JPanel switchableViewsPanel = new JPanel(new CardLayout());
58
59   private JPanel annotationComboBoxPanel = new JPanel();
60
61   private StructureFilterPanel gStructureFilterPanel;
62
63   private StructureFilterPanel ngStructureFilterPanel;
64
65   private StructureFilterPanel currentStructureFilterPanel;
66
67   private SearchPanel currentSearchPanel;
68
69   private SearchPanel gSearchPanel;
70
71   private SearchPanel ngSearchPanel;
72
73   private FurtherActionPanel currentFurtherActionPanel;
74
75   private FurtherActionPanel gFurtherActionPanel;
76
77   private FurtherActionPanel ngFurtherActionPanel;
78
79   public static final int ACTION_OPTION_SELECT = 1;
80
81   public static int ACTION_OPTION_HIDE = 2;
82
83   public static String NO_GRAPH_VIEW = "0";
84
85   public static String GRAPH_VIEW = "1";
86
87   private int actionOption = ACTION_OPTION_SELECT;
88
89   private HiddenColumns oldHiddenColumns;
90
91   public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap)
92   {
93     super(av, ap);
94     frame = new JInternalFrame();
95     frame.setContentPane(this);
96     frame.setLayer(JLayeredPane.PALETTE_LAYER);
97     Desktop.addInternalFrame(frame,
98             MessageManager.getString("label.select_by_annotation"), 520,
99             215);
100
101     addSliderChangeListener();
102     addSliderMouseListeners();
103
104     if (av.getAlignment().getAlignmentAnnotation() == null)
105     {
106       return;
107     }
108     setOldHiddenColumns(av.getAlignment().getHiddenColumns());
109     adjusting = true;
110
111     setAnnotations(new JComboBox<String>(getAnnotationItems(false)));
112     populateThresholdComboBox(threshold);
113     AnnotationColumnChooser lastChooser = av
114             .getAnnotationColumnSelectionState();
115     // restore Object state from the previous session if one exists
116     if (lastChooser != null)
117     {
118       currentSearchPanel = lastChooser
119               .getCurrentSearchPanel();
120       currentStructureFilterPanel = lastChooser
121               .getCurrentStructureFilterPanel();
122       annotations.setSelectedIndex(lastChooser
123               .getAnnotations().getSelectedIndex());
124       threshold.setSelectedIndex(lastChooser
125               .getThreshold().getSelectedIndex());
126       actionOption = lastChooser
127               .getActionOption();
128       percentThreshold.setSelected(lastChooser.percentThreshold
129               .isSelected());
130     }
131
132     try
133     {
134       jbInit();
135     } catch (Exception ex)
136     {
137     }
138     adjusting = false;
139
140     updateView();
141     frame.invalidate();
142     frame.pack();
143   }
144
145   @Override
146   protected void jbInit()
147   {
148     super.jbInit();
149
150     JPanel thresholdPanel = new JPanel();
151     thresholdPanel.setBorder(new TitledBorder(MessageManager
152             .getString("label.threshold_filter")));
153     thresholdPanel.setBackground(Color.white);
154     thresholdPanel.setFont(JvSwingUtils.getLabelFont());
155     thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]"));
156
157     percentThreshold.setBackground(Color.white);
158     percentThreshold.setFont(JvSwingUtils.getLabelFont());
159
160     JPanel actionPanel = new JPanel();
161     actionPanel.setBackground(Color.white);
162     actionPanel.setFont(JvSwingUtils.getLabelFont());
163
164     JPanel graphFilterView = new JPanel();
165     graphFilterView.setLayout(new MigLayout("", "[left][right]", "[][]"));
166     graphFilterView.setBackground(Color.white);
167
168     JPanel noGraphFilterView = new JPanel();
169     noGraphFilterView.setLayout(new MigLayout("", "[left][right]", "[][]"));
170     noGraphFilterView.setBackground(Color.white);
171
172     annotationComboBoxPanel.setBackground(Color.white);
173     annotationComboBoxPanel.setFont(JvSwingUtils.getLabelFont());
174
175     gSearchPanel = new SearchPanel(this);
176     ngSearchPanel = new SearchPanel(this);
177     gFurtherActionPanel = new FurtherActionPanel(this);
178     ngFurtherActionPanel = new FurtherActionPanel(this);
179     gStructureFilterPanel = new StructureFilterPanel(this);
180     ngStructureFilterPanel = new StructureFilterPanel(this);
181
182     thresholdPanel.add(getThreshold());
183     thresholdPanel.add(percentThreshold, "wrap");
184     thresholdPanel.add(slider, "grow");
185     thresholdPanel.add(thresholdValue, "span, wrap");
186
187     actionPanel.add(ok);
188     actionPanel.add(cancel);
189
190     graphFilterView.add(gSearchPanel, "grow, span, wrap");
191     graphFilterView.add(gStructureFilterPanel, "grow, span, wrap");
192     graphFilterView.add(thresholdPanel, "grow, span, wrap");
193     graphFilterView.add(gFurtherActionPanel);
194
195     noGraphFilterView.add(ngSearchPanel, "grow, span, wrap");
196     noGraphFilterView.add(ngStructureFilterPanel, "grow, span, wrap");
197     noGraphFilterView.add(ngFurtherActionPanel);
198
199     annotationComboBoxPanel.add(getAnnotations());
200     switchableViewsPanel.add(noGraphFilterView,
201             AnnotationColumnChooser.NO_GRAPH_VIEW);
202     switchableViewsPanel.add(graphFilterView,
203             AnnotationColumnChooser.GRAPH_VIEW);
204
205     this.setLayout(new BorderLayout());
206     this.add(annotationComboBoxPanel, java.awt.BorderLayout.PAGE_START);
207     this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER);
208     this.add(actionPanel, java.awt.BorderLayout.SOUTH);
209
210     selectedAnnotationChanged();
211     updateThresholdPanelToolTip();
212     this.validate();
213   }
214
215   protected void updateThresholdPanelToolTip()
216   {
217     thresholdValue.setToolTipText("");
218     slider.setToolTipText("");
219
220     String defaultTtip = MessageManager
221             .getString("info.change_threshold_mode_to_enable");
222
223     String thresh = getThreshold().getSelectedItem().toString();
224     if (thresh.equalsIgnoreCase("No Threshold"))
225     {
226       thresholdValue.setToolTipText(defaultTtip);
227       slider.setToolTipText(defaultTtip);
228     }
229   }
230
231   @Override
232   protected void reset()
233   {
234     if (this.getOldHiddenColumns() != null)
235     {
236       av.getColumnSelection().clear();
237
238       if (av.getAnnotationColumnSelectionState() != null)
239       {
240         HiddenColumns oldHidden = av
241                 .getAnnotationColumnSelectionState()
242                 .getOldHiddenColumns();
243         if (oldHidden != null && oldHidden.getListOfCols() != null
244                 && !oldHidden.getListOfCols().isEmpty())
245         {
246           for (Iterator<int[]> itr = oldHidden.getListOfCols()
247                   .iterator(); itr.hasNext();)
248           {
249             int positions[] = itr.next();
250             av.hideColumns(positions[0], positions[1]);
251           }
252         }
253         av.getAlignment().setHiddenColumns(oldHidden);
254       }
255       ap.paintAlignment(true);
256     }
257
258   }
259
260   @Override
261   public void valueChanged(boolean updateAllAnnotation)
262   {
263     if (slider.isEnabled())
264     {
265       getCurrentAnnotation().threshold.value = slider.getValue() / 1000f;
266       updateView();
267       propagateSeqAssociatedThreshold(updateAllAnnotation,
268               getCurrentAnnotation());
269       ap.paintAlignment(false);
270     }
271   }
272
273   @Override
274   public void updateView()
275   {
276     // Check if combobox is still adjusting
277     if (adjusting)
278     {
279       return;
280     }
281
282     AnnotationFilterParameter filterParams = new AnnotationFilterParameter();
283
284     setCurrentAnnotation(av.getAlignment().getAlignmentAnnotation()[annmap[getAnnotations()
285             .getSelectedIndex()]]);
286
287     int selectedThresholdItem = getSelectedThresholdItem(getThreshold()
288             .getSelectedIndex());
289
290     slider.setEnabled(true);
291     thresholdValue.setEnabled(true);
292     percentThreshold.setEnabled(true);
293
294     if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD)
295     {
296       slider.setEnabled(false);
297       thresholdValue.setEnabled(false);
298       thresholdValue.setText("");
299       percentThreshold.setEnabled(false);
300       // build filter params
301     }
302     else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD)
303     {
304       if (getCurrentAnnotation().threshold == null)
305       {
306         getCurrentAnnotation()
307                 .setThreshold(
308                         new jalview.datamodel.GraphLine(
309                                 (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin) / 2f,
310                                 "Threshold", Color.black));
311       }
312
313       adjusting = true;
314       float range = getCurrentAnnotation().graphMax * 1000
315               - getCurrentAnnotation().graphMin * 1000;
316
317       slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000));
318       slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
319       slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000));
320       
321       setThresholdValueText();
322
323       slider.setMajorTickSpacing((int) (range / 10f));
324       slider.setEnabled(true);
325       thresholdValue.setEnabled(true);
326       adjusting = false;
327
328       // build filter params
329       filterParams
330               .setThresholdType(AnnotationFilterParameter.ThresholdType.NO_THRESHOLD);
331       if (getCurrentAnnotation().graph != AlignmentAnnotation.NO_GRAPH)
332       {
333         filterParams
334                 .setThresholdValue(getCurrentAnnotation().threshold.value);
335
336         if (selectedThresholdItem == AnnotationColourGradient.ABOVE_THRESHOLD)
337         {
338           filterParams
339                   .setThresholdType(AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD);
340         }
341         else if (selectedThresholdItem == AnnotationColourGradient.BELOW_THRESHOLD)
342         {
343           filterParams
344                   .setThresholdType(AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD);
345         }
346       }
347     }
348
349     updateThresholdPanelToolTip();
350     if (currentStructureFilterPanel != null)
351     {
352       if (currentStructureFilterPanel.alphaHelix.isSelected())
353       {
354         filterParams.setFilterAlphaHelix(true);
355       }
356       if (currentStructureFilterPanel.betaStrand.isSelected())
357       {
358         filterParams.setFilterBetaSheet(true);
359       }
360       if (currentStructureFilterPanel.turn.isSelected())
361       {
362         filterParams.setFilterTurn(true);
363       }
364     }
365
366     if (currentSearchPanel != null)
367     {
368
369       if (!currentSearchPanel.searchBox.getText().isEmpty())
370       {
371         currentSearchPanel.description.setEnabled(true);
372         currentSearchPanel.displayName.setEnabled(true);
373         filterParams.setRegexString(currentSearchPanel.searchBox.getText());
374         if (currentSearchPanel.displayName.isSelected())
375         {
376           filterParams
377                   .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING);
378         }
379         if (currentSearchPanel.description.isSelected())
380         {
381           filterParams
382                   .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION);
383         }
384       }
385       else
386       {
387         currentSearchPanel.description.setEnabled(false);
388         currentSearchPanel.displayName.setEnabled(false);
389       }
390     }
391
392     av.getColumnSelection().filterAnnotations(
393             getCurrentAnnotation().annotations, filterParams);
394
395     av.showAllHiddenColumns();
396     if (getActionOption() == ACTION_OPTION_HIDE)
397     {
398       av.hideSelectedColumns();
399     }
400
401     filterParams = null;
402     av.setAnnotationColumnSelectionState(this);
403     ap.paintAlignment(true);
404   }
405
406   public HiddenColumns getOldHiddenColumns()
407   {
408     return oldHiddenColumns;
409   }
410
411   public void setOldHiddenColumns(HiddenColumns currentHiddenColumns)
412   {
413     if (currentHiddenColumns != null)
414     {
415       this.oldHiddenColumns = new HiddenColumns(currentHiddenColumns);
416     }
417   }
418
419   public FurtherActionPanel getCurrentFutherActionPanel()
420   {
421     return currentFurtherActionPanel;
422   }
423
424   public void setCurrentFutherActionPanel(
425           FurtherActionPanel currentFutherActionPanel)
426   {
427     this.currentFurtherActionPanel = currentFutherActionPanel;
428   }
429
430   public SearchPanel getCurrentSearchPanel()
431   {
432     return currentSearchPanel;
433   }
434
435   public void setCurrentSearchPanel(SearchPanel currentSearchPanel)
436   {
437     this.currentSearchPanel = currentSearchPanel;
438   }
439
440   public int getActionOption()
441   {
442     return actionOption;
443   }
444
445   public void setActionOption(int actionOption)
446   {
447     this.actionOption = actionOption;
448   }
449
450   public StructureFilterPanel getCurrentStructureFilterPanel()
451   {
452     return currentStructureFilterPanel;
453   }
454
455   public void setCurrentStructureFilterPanel(
456           StructureFilterPanel currentStructureFilterPanel)
457   {
458     this.currentStructureFilterPanel = currentStructureFilterPanel;
459   }
460
461   public void select_action(ActionEvent actionEvent)
462   {
463     JRadioButton radioButton = (JRadioButton) actionEvent.getSource();
464     if (radioButton.isSelected())
465     {
466       setActionOption(ACTION_OPTION_SELECT);
467       updateView();
468     }
469   }
470
471   public void hide_action(ActionEvent actionEvent)
472   {
473     JRadioButton radioButton = (JRadioButton) actionEvent.getSource();
474     if (radioButton.isSelected())
475     {
476       setActionOption(ACTION_OPTION_HIDE);
477       updateView();
478     }
479   }
480
481   @Override
482   public void itemStateChanged(ItemEvent e)
483   {
484     selectedAnnotationChanged();
485   }
486
487   @Override
488   public void selectedAnnotationChanged()
489   {
490     String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW;
491     if (av.getAlignment().getAlignmentAnnotation()[annmap[getAnnotations()
492             .getSelectedIndex()]].graph != AlignmentAnnotation.NO_GRAPH)
493     {
494       currentView = AnnotationColumnChooser.GRAPH_VIEW;
495     }
496
497     gSearchPanel.syncState();
498     gFurtherActionPanel.syncState();
499     gStructureFilterPanel.syncState();
500
501     ngSearchPanel.syncState();
502     ngFurtherActionPanel.syncState();
503     ngStructureFilterPanel.syncState();
504
505     CardLayout switchableViewsLayout = (CardLayout) switchableViewsPanel
506             .getLayout();
507     switchableViewsLayout.show(switchableViewsPanel, currentView);
508     updateView();
509   }
510
511   public class FurtherActionPanel extends JPanel
512   {
513     private AnnotationColumnChooser aColChooser;
514
515     private JRadioButton hideOption = new JRadioButton();
516
517     private JRadioButton selectOption = new JRadioButton();
518
519     private ButtonGroup optionsGroup = new ButtonGroup();
520
521     public FurtherActionPanel(AnnotationColumnChooser aColChooser)
522     {
523       this.aColChooser = aColChooser;
524       JvSwingUtils.jvInitComponent(selectOption, "action.select");
525       selectOption.addActionListener(new ActionListener()
526       {
527         @Override
528         public void actionPerformed(ActionEvent actionEvent)
529         {
530           selectRadioAction(actionEvent);
531         }
532       });
533
534       JvSwingUtils.jvInitComponent(hideOption, "action.hide");
535       hideOption.addActionListener(new ActionListener()
536       {
537         @Override
538         public void actionPerformed(ActionEvent actionEvent)
539         {
540           hideRadioAction(actionEvent);
541         }
542       });
543
544       optionsGroup.add(selectOption);
545       optionsGroup.add(hideOption);
546       optionsGroup.setSelected(selectOption.getModel(), true);
547
548       JvSwingUtils.jvInitComponent(this);
549       syncState();
550
551       this.add(selectOption);
552       this.add(hideOption);
553     }
554
555     public void selectRadioAction(ActionEvent actionEvent)
556     {
557       aColChooser.setCurrentFutherActionPanel(this);
558       aColChooser.select_action(actionEvent);
559     }
560
561     public void hideRadioAction(ActionEvent actionEvent)
562     {
563       aColChooser.setCurrentFutherActionPanel(this);
564       aColChooser.hide_action(actionEvent);
565     }
566
567     public void syncState()
568     {
569       if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE)
570       {
571         this.optionsGroup.setSelected(this.hideOption.getModel(), true);
572       }
573       else
574       {
575         this.optionsGroup.setSelected(this.selectOption.getModel(), true);
576       }
577     }
578   }
579
580   public class StructureFilterPanel extends JPanel
581   {
582     private AnnotationColumnChooser aColChooser;
583
584     private JCheckBox alphaHelix = new JCheckBox();
585
586     private JCheckBox betaStrand = new JCheckBox();
587
588     private JCheckBox turn = new JCheckBox();
589
590     private JCheckBox all = new JCheckBox();
591
592     public StructureFilterPanel(AnnotationColumnChooser aColChooser)
593     {
594       this.aColChooser = aColChooser;
595
596       JvSwingUtils.jvInitComponent(alphaHelix, "label.alpha_helix");
597       alphaHelix.addActionListener(new ActionListener()
598       {
599         @Override
600         public void actionPerformed(ActionEvent actionEvent)
601         {
602           alphaHelix_actionPerformed();
603         }
604       });
605
606       JvSwingUtils.jvInitComponent(betaStrand, "label.beta_strand");
607       betaStrand.addActionListener(new ActionListener()
608       {
609         @Override
610         public void actionPerformed(ActionEvent actionEvent)
611         {
612           betaStrand_actionPerformed();
613         }
614       });
615
616       JvSwingUtils.jvInitComponent(turn, "label.turn");
617       turn.addActionListener(new ActionListener()
618       {
619         @Override
620         public void actionPerformed(ActionEvent actionEvent)
621         {
622           turn_actionPerformed();
623         }
624       });
625
626       JvSwingUtils.jvInitComponent(all, "label.select_all");
627       all.addActionListener(new ActionListener()
628       {
629         @Override
630         public void actionPerformed(ActionEvent actionEvent)
631         {
632           all_actionPerformed();
633         }
634       });
635
636       this.setBorder(new TitledBorder(MessageManager
637               .getString("label.structures_filter")));
638       JvSwingUtils.jvInitComponent(this);
639
640       this.add(all);
641       this.add(alphaHelix);
642       this.add(betaStrand);
643       this.add(turn);
644     }
645
646     public void alphaHelix_actionPerformed()
647     {
648       updateSelectAllState();
649       aColChooser.setCurrentStructureFilterPanel(this);
650       aColChooser.updateView();
651     }
652
653     public void betaStrand_actionPerformed()
654     {
655       updateSelectAllState();
656       aColChooser.setCurrentStructureFilterPanel(this);
657       aColChooser.updateView();
658     }
659
660     public void turn_actionPerformed()
661     {
662       updateSelectAllState();
663       aColChooser.setCurrentStructureFilterPanel(this);
664       aColChooser.updateView();
665     }
666
667     public void all_actionPerformed()
668     {
669       if (all.isSelected())
670       {
671         alphaHelix.setSelected(true);
672         betaStrand.setSelected(true);
673         turn.setSelected(true);
674       }
675       else
676       {
677         alphaHelix.setSelected(false);
678         betaStrand.setSelected(false);
679         turn.setSelected(false);
680       }
681       aColChooser.setCurrentStructureFilterPanel(this);
682       aColChooser.updateView();
683     }
684
685     public void updateSelectAllState()
686     {
687       if (alphaHelix.isSelected() && betaStrand.isSelected()
688               && turn.isSelected())
689       {
690         all.setSelected(true);
691       }
692       else
693       {
694         all.setSelected(false);
695       }
696     }
697
698     public void syncState()
699     {
700       StructureFilterPanel sfp = aColChooser
701               .getCurrentStructureFilterPanel();
702       if (sfp != null)
703       {
704         alphaHelix.setSelected(sfp.alphaHelix.isSelected());
705         betaStrand.setSelected(sfp.betaStrand.isSelected());
706         turn.setSelected(sfp.turn.isSelected());
707         if (sfp.all.isSelected())
708         {
709           all.setSelected(true);
710           alphaHelix.setSelected(true);
711           betaStrand.setSelected(true);
712           turn.setSelected(true);
713         }
714       }
715
716     }
717   }
718
719   public class SearchPanel extends JPanel
720   {
721     private AnnotationColumnChooser aColChooser;
722
723     private JCheckBox displayName = new JCheckBox();
724
725     private JCheckBox description = new JCheckBox();
726
727     private JTextField searchBox = new JTextField(10);
728
729     public SearchPanel(AnnotationColumnChooser aColChooser)
730     {
731
732       this.aColChooser = aColChooser;
733       JvSwingUtils.jvInitComponent(this);
734       this.setBorder(new TitledBorder(MessageManager
735               .getString("label.search_filter")));
736
737       JvSwingUtils.jvInitComponent(searchBox);
738       searchBox.setToolTipText(MessageManager
739               .getString("info.enter_search_text_here"));
740       searchBox.getDocument().addDocumentListener(new DocumentListener()
741       {
742         @Override
743         public void insertUpdate(DocumentEvent e)
744         {
745           searchStringAction();
746         }
747
748         @Override
749         public void removeUpdate(DocumentEvent e)
750         {
751           searchStringAction();
752         }
753
754         @Override
755         public void changedUpdate(DocumentEvent e)
756         {
757           searchStringAction();
758         }
759       });
760
761       JvSwingUtils.jvInitComponent(displayName, "label.label");
762       displayName.setEnabled(false);
763       displayName.addActionListener(new ActionListener()
764       {
765         @Override
766         public void actionPerformed(ActionEvent actionEvent)
767         {
768           displayNameCheckboxAction();
769         }
770       });
771
772       JvSwingUtils.jvInitComponent(description, "label.description");
773       description.setEnabled(false);
774       description.addActionListener(new ActionListener()
775       {
776         @Override
777         public void actionPerformed(ActionEvent actionEvent)
778         {
779           discriptionCheckboxAction();
780         }
781       });
782
783       syncState();
784       this.add(searchBox);
785       this.add(displayName);
786       this.add(description);
787     }
788
789     public void displayNameCheckboxAction()
790     {
791       aColChooser.setCurrentSearchPanel(this);
792       aColChooser.updateView();
793     }
794
795     public void discriptionCheckboxAction()
796     {
797       aColChooser.setCurrentSearchPanel(this);
798       aColChooser.updateView();
799     }
800
801     public void searchStringAction()
802     {
803       aColChooser.setCurrentSearchPanel(this);
804       aColChooser.updateView();
805       updateSearchPanelToolTips();
806     }
807
808     public void syncState()
809     {
810       SearchPanel sp = aColChooser.getCurrentSearchPanel();
811       if (sp != null)
812       {
813         description.setEnabled(sp.description.isEnabled());
814         description.setSelected(sp.description.isSelected());
815
816         displayName.setEnabled(sp.displayName.isEnabled());
817         displayName.setSelected(sp.displayName.isSelected());
818
819         searchBox.setText(sp.searchBox.getText());
820       }
821       updateSearchPanelToolTips();
822     }
823
824     public void updateSearchPanelToolTips()
825     {
826       String defaultTtip = MessageManager
827               .getString("info.enter_search_text_to_enable");
828       String labelTtip = MessageManager.formatMessage(
829               "info.search_in_annotation_label", annotations
830                       .getSelectedItem().toString());
831       String descTtip = MessageManager.formatMessage(
832               "info.search_in_annotation_description", annotations
833                       .getSelectedItem().toString());
834       displayName.setToolTipText(displayName.isEnabled() ? labelTtip
835               : defaultTtip);
836       description.setToolTipText(description.isEnabled() ? descTtip
837               : defaultTtip);
838     }
839   }
840
841 }