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