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