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