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