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