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