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