merge
[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
573           ItemListener
574   {
575     private AnnotationColumnChooser aColChooser;
576
577     private Choice furtherAction = new Choice();
578
579     public FurtherActionPanel(AnnotationColumnChooser aColChooser)
580     {
581       this.aColChooser = aColChooser;
582       furtherAction.addItem("Select");
583       furtherAction.addItem("Hide");
584       furtherAction.addItemListener(this);
585       syncState();
586
587       // this.setTitle("Filter Actions");
588       // this.setFont(JvSwingUtils.getLabelFont());
589
590       this.add(furtherAction);
591     }
592
593     public void syncState()
594     {
595       if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE)
596       {
597         furtherAction.select("Hide");
598       }
599       else
600       {
601         furtherAction.select("Select");
602       }
603     }
604
605     @Override
606     public void itemStateChanged(ItemEvent e)
607     {
608       aColChooser.setCurrentFutherActionPanel(this);
609       if (furtherAction.getSelectedItem().equalsIgnoreCase("Select"))
610       {
611         setActionOption(ACTION_OPTION_SELECT);
612         updateView();
613       }
614       else
615       {
616         setActionOption(ACTION_OPTION_HIDE);
617         updateView();
618       }
619
620     }
621   }
622
623   public class StructureFilterPanel extends TitledPanel implements
624           ItemListener
625   {
626     private AnnotationColumnChooser aColChooser;
627
628     private Checkbox alphaHelix = new Checkbox();
629
630     private Checkbox betaStrand = new Checkbox();
631
632     private Checkbox turn = new Checkbox();
633
634     private Checkbox all = new Checkbox();
635
636     public StructureFilterPanel(AnnotationColumnChooser aColChooser)
637     {
638       this.aColChooser = aColChooser;
639
640       alphaHelix.setLabel(MessageManager.getString("label.alpha_helix"));
641       alphaHelix.setBackground(Color.white);
642
643       alphaHelix.addItemListener(this);
644
645       betaStrand.setLabel(MessageManager.getString("label.beta_strand"));
646       betaStrand.setBackground(Color.white);
647       betaStrand.addItemListener(this);
648
649       turn.setLabel(MessageManager.getString("label.turn"));
650       turn.setBackground(Color.white);
651       turn.addItemListener(this);
652
653       all.setLabel(MessageManager.getString("label.select_all"));
654       all.setBackground(Color.white);
655       all.addItemListener(this);
656
657       this.setBackground(Color.white);
658       this.setTitle("Structure Filter");
659       // this.setFont(JvSwingUtils.getLabelFont());
660
661       this.add(all);
662       this.add(alphaHelix);
663       this.add(betaStrand);
664       this.add(turn);
665     }
666
667     public void alphaHelix_actionPerformed()
668     {
669       updateSelectAllState();
670       aColChooser.setCurrentStructureFilterPanel(this);
671       aColChooser.updateView();
672     }
673
674     public void betaStrand_actionPerformed()
675     {
676       updateSelectAllState();
677       aColChooser.setCurrentStructureFilterPanel(this);
678       aColChooser.updateView();
679     }
680
681     public void turn_actionPerformed()
682     {
683       updateSelectAllState();
684       aColChooser.setCurrentStructureFilterPanel(this);
685       aColChooser.updateView();
686     }
687
688     public void all_actionPerformed()
689     {
690       if (all.getState())
691       {
692         alphaHelix.setState(true);
693         betaStrand.setState(true);
694         turn.setState(true);
695       }
696       else
697       {
698         alphaHelix.setState(false);
699         betaStrand.setState(false);
700         turn.setState(false);
701       }
702       aColChooser.setCurrentStructureFilterPanel(this);
703       aColChooser.updateView();
704     }
705
706     public void updateSelectAllState()
707     {
708       if (alphaHelix.getState() && betaStrand.getState() && turn.getState())
709       {
710         all.setState(true);
711       }
712       else
713       {
714         all.setState(false);
715       }
716     }
717
718     public void syncState()
719     {
720       StructureFilterPanel sfp = aColChooser
721               .getCurrentStructureFilterPanel();
722       if (sfp != null)
723       {
724         alphaHelix.setState(sfp.alphaHelix.getState());
725         betaStrand.setState(sfp.betaStrand.getState());
726         turn.setState(sfp.turn.getState());
727         if (sfp.all.getState())
728         {
729           all.setState(true);
730           alphaHelix.setState(true);
731           betaStrand.setState(true);
732           turn.setState(true);
733         }
734       }
735
736     }
737
738     @Override
739     public void itemStateChanged(ItemEvent e)
740     {
741       if (e.getSource() == alphaHelix)
742       {
743         alphaHelix_actionPerformed();
744       }
745       else if (e.getSource() == betaStrand)
746       {
747         betaStrand_actionPerformed();
748       }
749       else if (e.getSource() == turn)
750       {
751         turn_actionPerformed();
752       }
753       else if (e.getSource() == all)
754       {
755         all_actionPerformed();
756       }
757     }
758   }
759
760   public class SearchPanel extends TitledPanel implements ItemListener
761   {
762     private AnnotationColumnChooser aColChooser;
763
764     private Checkbox displayName = new Checkbox();
765
766     private Checkbox description = new Checkbox();
767
768     private TextField searchBox = new TextField(10);
769
770     public SearchPanel(AnnotationColumnChooser aColChooser)
771     {
772
773       this.aColChooser = aColChooser;
774       searchBox.addTextListener(new TextListener()
775       {
776
777         @Override
778         public void textValueChanged(TextEvent e)
779         {
780           searchStringAction();
781
782         }
783
784       });
785
786       displayName.setLabel(MessageManager.getString("label.display_name"));
787       displayName.setEnabled(false);
788       displayName.addItemListener(this);
789
790       description.setLabel(MessageManager.getString("label.description"));
791       description.setEnabled(false);
792       description.addItemListener(this);
793       this.setTitle("Search Filter");
794       // this.setFont(JvSwingUtils.getLabelFont());
795
796       syncState();
797       this.add(searchBox);
798       this.add(displayName);
799       this.add(description);
800     }
801
802     public void displayNameCheckboxAction()
803     {
804       aColChooser.setCurrentSearchPanel(this);
805       aColChooser.updateView();
806     }
807
808     public void discriptionCheckboxAction()
809     {
810       aColChooser.setCurrentSearchPanel(this);
811       aColChooser.updateView();
812     }
813
814     public void searchStringAction()
815     {
816       aColChooser.setCurrentSearchPanel(this);
817       aColChooser.updateView();
818     }
819
820     public void syncState()
821     {
822       SearchPanel sp = aColChooser.getCurrentSearchPanel();
823       if (sp != null)
824       {
825         description.setEnabled(sp.description.isEnabled());
826         description.setState(sp.description.getState());
827
828         displayName.setEnabled(sp.displayName.isEnabled());
829         displayName.setState(sp.displayName.getState());
830
831         searchBox.setText(sp.searchBox.getText());
832       }
833     }
834
835     @Override
836     public void itemStateChanged(ItemEvent e)
837     {
838       if (e.getSource() == displayName)
839       {
840         displayNameCheckboxAction();
841       }
842       else if (e.getSource() == description)
843       {
844         discriptionCheckboxAction();
845       }
846
847     }
848   }
849
850   public void actionPerformed(ActionEvent evt)
851   {
852     if (evt.getSource() == thresholdValue)
853     {
854       try
855       {
856         float f = new Float(thresholdValue.getText()).floatValue();
857         slider.setValue((int) (f * 1000));
858         adjustmentValueChanged(null);
859       } catch (NumberFormatException ex)
860       {
861       }
862     }
863
864     else if (evt.getSource() == ok)
865     {
866       ok_actionPerformed(null);
867     }
868     else if (evt.getSource() == cancel)
869     {
870       cancel_actionPerformed(null);
871     }
872     else if (evt.getSource() == thresholdValue)
873     {
874       thresholdValue_actionPerformed(null);
875     }
876     else
877     {
878       updateView();
879     }
880   }
881
882   @Override
883   public void mouseClicked(MouseEvent e)
884   {
885     // TODO Auto-generated method stub
886
887   }
888
889   @Override
890   public void mousePressed(MouseEvent e)
891   {
892     if (e.getSource() == slider)
893     {
894       updateView();
895     }
896
897   }
898
899   @Override
900   public void mouseReleased(MouseEvent e)
901   {
902     if (e.getSource() == slider)
903     {
904       updateView();
905     }
906   }
907
908   @Override
909   public void mouseEntered(MouseEvent e)
910   {
911     if (e.getSource() == slider)
912     {
913       updateView();
914     }
915   }
916
917   @Override
918   public void mouseExited(MouseEvent e)
919   {
920     if (e.getSource() == slider)
921     {
922       updateView();
923     }
924   }
925
926 }