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