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