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