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