JAL-2629 add ability to add and select a DB for hmmsearch
[jalview.git] / src / jalview / jbgui / GAlignFrame.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.jbgui;
22
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.api.SplitContainerI;
25 import jalview.bin.Cache;
26 import jalview.gui.JvSwingUtils;
27 import jalview.gui.Preferences;
28 import jalview.io.FileFormatException;
29 import jalview.io.FileFormats;
30 import jalview.util.MessageManager;
31 import jalview.util.Platform;
32
33 import java.awt.BorderLayout;
34 import java.awt.Color;
35 import java.awt.GridLayout;
36 import java.awt.Toolkit;
37 import java.awt.event.ActionEvent;
38 import java.awt.event.ActionListener;
39 import java.awt.event.FocusAdapter;
40 import java.awt.event.FocusEvent;
41 import java.awt.event.KeyEvent;
42 import java.awt.event.MouseAdapter;
43 import java.awt.event.MouseEvent;
44 import java.io.IOException;
45 import java.util.HashMap;
46 import java.util.Map;
47
48 import javax.swing.BorderFactory;
49 import javax.swing.ButtonGroup;
50 import javax.swing.JCheckBoxMenuItem;
51 import javax.swing.JInternalFrame;
52 import javax.swing.JLabel;
53 import javax.swing.JMenu;
54 import javax.swing.JMenuBar;
55 import javax.swing.JMenuItem;
56 import javax.swing.JPanel;
57 import javax.swing.JRadioButtonMenuItem;
58 import javax.swing.JTabbedPane;
59 import javax.swing.KeyStroke;
60 import javax.swing.event.ChangeEvent;
61 import javax.swing.event.MenuEvent;
62 import javax.swing.event.MenuListener;
63
64 public class GAlignFrame extends JInternalFrame
65 {
66   protected JMenuBar alignFrameMenuBar = new JMenuBar();
67
68   protected JMenuItem closeMenuItem = new JMenuItem();
69
70   protected JMenu webService = new JMenu();
71
72   protected JMenu hmmerMenu = new JMenu();
73
74   protected JMenu hmmAlign = new JMenu();
75
76   protected JMenuItem hmmAlignRun = new JMenuItem();
77
78   protected JMenuItem hmmAlignSettings = new JMenuItem();
79
80   protected JMenu hmmSearch = new JMenu();
81
82   protected JMenuItem hmmSearchRun = new JMenuItem();
83
84   protected JMenuItem hmmSearchSettings = new JMenuItem();
85
86   protected JMenuItem addDatabase = new JMenuItem();
87
88   protected JMenu hmmBuild = new JMenu();
89
90   protected JMenuItem hmmBuildRun = new JMenuItem();
91
92   protected JMenuItem hmmBuildSettings = new JMenuItem();
93
94   protected JMenuItem webServiceNoServices;
95
96   protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem();
97
98   protected JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem();
99
100   protected JMenu sortByAnnotScore = new JMenu();
101
102   public JLabel statusBar = new JLabel();
103
104   protected JMenu outputTextboxMenu = new JMenu();
105
106   protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem();
107
108   protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
109
110   protected JCheckBoxMenuItem showNonconservedMenuItem = new JCheckBoxMenuItem();
111
112   protected JMenuItem undoMenuItem = new JMenuItem();
113
114   protected JMenuItem redoMenuItem = new JMenuItem();
115
116   protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();
117
118   protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem();
119
120   public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem();
121
122   JMenuItem copy = new JMenuItem();
123
124   JMenuItem cut = new JMenuItem();
125
126   JMenu pasteMenu = new JMenu();
127
128   protected JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
129
130   protected JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem();
131
132   protected JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem();
133
134   protected JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem();
135
136   protected JCheckBoxMenuItem applyToAllGroups;
137
138   protected JMenu colourMenu = new JMenu();
139
140   protected JMenuItem textColour;
141
142   protected JCheckBoxMenuItem conservationMenuItem;
143
144   protected JMenuItem modifyConservation;
145
146   protected JCheckBoxMenuItem abovePIDThreshold;
147
148   protected JMenuItem modifyPID;
149
150   protected JMenuItem annotationColour;
151
152   protected JMenu sortByTreeMenu = new JMenu();
153
154   protected JMenu sort = new JMenu();
155
156   protected JMenuItem calculateTree = new JMenuItem();
157
158   protected JCheckBoxMenuItem padGapsMenuitem = new JCheckBoxMenuItem();
159
160   protected JCheckBoxMenuItem showNpFeatsMenuitem = new JCheckBoxMenuItem();
161
162   protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem();
163
164   protected JMenuItem showTranslation = new JMenuItem();
165
166   protected JMenuItem showReverse = new JMenuItem();
167
168   protected JMenuItem showReverseComplement = new JMenuItem();
169
170   protected JMenu showProducts = new JMenu();
171
172   protected JMenuItem runGroovy = new JMenuItem();
173
174   protected JCheckBoxMenuItem autoCalculate = new JCheckBoxMenuItem();
175
176   protected JCheckBoxMenuItem sortByTree = new JCheckBoxMenuItem();
177
178   protected JCheckBoxMenuItem listenToViewSelections = new JCheckBoxMenuItem();
179
180   protected JPanel statusPanel = new JPanel();
181
182   protected JMenuItem showAllSeqAnnotations = new JMenuItem();
183
184   protected JMenuItem hideAllSeqAnnotations = new JMenuItem();
185
186   protected JMenuItem showAllAlAnnotations = new JMenuItem();
187
188   protected JMenuItem hideAllAlAnnotations = new JMenuItem();
189
190   protected JCheckBoxMenuItem showComplementMenuItem = new JCheckBoxMenuItem();
191
192   protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();
193
194   protected JTabbedPane tabbedPane = new JTabbedPane();
195
196   protected JMenuItem reload = new JMenuItem();
197
198   protected JMenu formatMenu = new JMenu();
199
200   protected JCheckBoxMenuItem idRightAlign = new JCheckBoxMenuItem();
201
202   protected JCheckBoxMenuItem centreColumnLabelsMenuItem = new JCheckBoxMenuItem();
203
204   protected JCheckBoxMenuItem followHighlightMenuItem = new JCheckBoxMenuItem();
205
206   protected JMenuItem gatherViews = new JMenuItem();
207
208   protected JMenuItem expandViews = new JMenuItem();
209
210   protected JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem();
211
212   protected JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem();
213
214   protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();
215
216   protected JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem();
217
218   protected JCheckBoxMenuItem normaliseSequenceLogo = new JCheckBoxMenuItem();
219
220   protected JCheckBoxMenuItem showInformationHistogram = new JCheckBoxMenuItem();
221
222   protected JCheckBoxMenuItem showHMMSequenceLogo = new JCheckBoxMenuItem();
223
224   protected JCheckBoxMenuItem normaliseHMMSequenceLogo = new JCheckBoxMenuItem();
225
226   protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem();
227
228   private SequenceAnnotationOrder annotationSortOrder;
229
230   private boolean showAutoCalculatedAbove = false;
231
232   private Map<KeyStroke, JMenuItem> accelerators = new HashMap<>();
233
234   private SplitContainerI splitFrame;
235
236   public GAlignFrame()
237   {
238     try
239     {
240       jbInit();
241       setJMenuBar(alignFrameMenuBar);
242
243       // dynamically fill save as menu with available formats
244       for (String ff : FileFormats.getInstance().getWritableFormats(true))
245       {
246         JMenuItem item = new JMenuItem(ff);
247
248         item.addActionListener(new ActionListener()
249         {
250           @Override
251           public void actionPerformed(ActionEvent e)
252           {
253             outputText_actionPerformed(e);
254           }
255         });
256
257         outputTextboxMenu.add(item);
258       }
259     } catch (Exception e)
260     {
261       System.err.println(e.toString());
262     }
263
264     if (!Platform.isAMac())
265     {
266       closeMenuItem.setMnemonic('C');
267       outputTextboxMenu.setMnemonic('T');
268       undoMenuItem.setMnemonic('Z');
269       redoMenuItem.setMnemonic('0');
270       copy.setMnemonic('C');
271       cut.setMnemonic('U');
272       pasteMenu.setMnemonic('P');
273       reload.setMnemonic('R');
274     }
275   }
276
277   private void jbInit() throws Exception
278   {
279     initColourMenu();
280     initHMMERMenu();
281   
282     JMenuItem saveAs = new JMenuItem(
283             MessageManager.getString("action.save_as"));
284     ActionListener al = new ActionListener()
285     {
286       @Override
287       public void actionPerformed(ActionEvent e)
288       {
289         saveAs_actionPerformed(e);
290       }
291     };
292   
293     // FIXME getDefaultToolkit throws an exception in Headless mode
294     KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
295             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
296                     | KeyEvent.SHIFT_MASK,
297             false);
298     addMenuActionAndAccelerator(keyStroke, saveAs, al);
299   
300     closeMenuItem.setText(MessageManager.getString("action.close"));
301     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_W,
302             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
303     al = new ActionListener()
304     {
305       @Override
306       public void actionPerformed(ActionEvent e)
307       {
308         closeMenuItem_actionPerformed(false);
309       }
310     };
311     addMenuActionAndAccelerator(keyStroke, closeMenuItem, al);
312   
313     JMenu editMenu = new JMenu(MessageManager.getString("action.edit"));
314     JMenu viewMenu = new JMenu(MessageManager.getString("action.view"));
315     JMenu annotationsMenu = new JMenu(
316             MessageManager.getString("action.annotations"));
317     JMenu showMenu = new JMenu(MessageManager.getString("action.show"));
318     colourMenu.setText(MessageManager.getString("action.colour"));
319     JMenu calculateMenu = new JMenu(
320             MessageManager.getString("action.calculate"));
321     webService.setText(MessageManager.getString("action.web_service"));
322     hmmerMenu.setText(MessageManager.getString("action.hmmer"));
323     String status = Cache.getProperty("HMMER_FUNCTIONING");
324     if ("false".equals(status) || status == null)
325     {
326       hmmerMenu.setEnabled(false);
327     }
328     else
329     {
330       hmmerMenu.setEnabled(true);
331     }
332     hmmerMenu.addActionListener(new ActionListener()
333     {
334       @Override
335       public void actionPerformed(ActionEvent e)
336       {
337         hmmerMenu_actionPerformed(e);
338       }
339     });
340     JMenuItem selectAllSequenceMenuItem = new JMenuItem(
341             MessageManager.getString("action.select_all"));
342     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A,
343             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
344     al = new ActionListener()
345     {
346       @Override
347       public void actionPerformed(ActionEvent e)
348       {
349         selectAllSequenceMenuItem_actionPerformed(e);
350       }
351     };
352     addMenuActionAndAccelerator(keyStroke, selectAllSequenceMenuItem, al);
353   
354     JMenuItem deselectAllSequenceMenuItem = new JMenuItem(
355             MessageManager.getString("action.deselect_all"));
356     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
357     al = new ActionListener()
358     {
359       @Override
360       public void actionPerformed(ActionEvent e)
361       {
362         deselectAllSequenceMenuItem_actionPerformed(e);
363       }
364     };
365     addMenuActionAndAccelerator(keyStroke, deselectAllSequenceMenuItem, al);
366   
367     JMenuItem invertSequenceMenuItem = new JMenuItem(
368             MessageManager.getString("action.invert_sequence_selection"));
369     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
370             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
371     al = new ActionListener()
372     {
373       @Override
374       public void actionPerformed(ActionEvent e)
375       {
376         invertSequenceMenuItem_actionPerformed(e);
377       }
378     };
379     addMenuActionAndAccelerator(keyStroke, invertSequenceMenuItem, al);
380   
381     JMenuItem grpsFromSelection = new JMenuItem(
382             MessageManager.getString("action.make_groups_selection"));
383     grpsFromSelection.addActionListener(new ActionListener()
384     {
385       @Override
386       public void actionPerformed(ActionEvent e)
387       {
388         makeGrpsFromSelection_actionPerformed(e);
389       }
390     });
391     JMenuItem expandAlignment = new JMenuItem(
392             MessageManager.getString("action.view_flanking_regions"));
393     expandAlignment.setToolTipText(
394             MessageManager.getString("label.view_flanking_regions"));
395     expandAlignment.addActionListener(new ActionListener()
396     {
397       @Override
398       public void actionPerformed(ActionEvent e)
399       {
400         expand_newalign(e);
401       }
402     });
403     JMenuItem remove2LeftMenuItem = new JMenuItem(
404             MessageManager.getString("action.remove_left"));
405     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_L,
406             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
407     al = new ActionListener()
408     {
409       @Override
410       public void actionPerformed(ActionEvent e)
411       {
412         remove2LeftMenuItem_actionPerformed(e);
413       }
414     };
415     addMenuActionAndAccelerator(keyStroke, remove2LeftMenuItem, al);
416   
417     JMenuItem remove2RightMenuItem = new JMenuItem(
418             MessageManager.getString("action.remove_right"));
419     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R,
420             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
421     al = new ActionListener()
422     {
423       @Override
424       public void actionPerformed(ActionEvent e)
425       {
426         remove2RightMenuItem_actionPerformed(e);
427       }
428     };
429     addMenuActionAndAccelerator(keyStroke, remove2RightMenuItem, al);
430   
431     JMenuItem removeGappedColumnMenuItem = new JMenuItem(
432             MessageManager.getString("action.remove_empty_columns"));
433     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
434             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
435     al = new ActionListener()
436     {
437       @Override
438       public void actionPerformed(ActionEvent e)
439       {
440         removeGappedColumnMenuItem_actionPerformed(e);
441       }
442     };
443     addMenuActionAndAccelerator(keyStroke, removeGappedColumnMenuItem, al);
444   
445     JMenuItem removeAllGapsMenuItem = new JMenuItem(
446             MessageManager.getString("action.remove_all_gaps"));
447     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E,
448             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
449                     | KeyEvent.SHIFT_MASK,
450             false);
451     al = new ActionListener()
452     {
453       @Override
454       public void actionPerformed(ActionEvent e)
455       {
456         removeAllGapsMenuItem_actionPerformed(e);
457       }
458     };
459     addMenuActionAndAccelerator(keyStroke, removeAllGapsMenuItem, al);
460   
461     JMenuItem justifyLeftMenuItem = new JMenuItem(
462             MessageManager.getString("action.left_justify_alignment"));
463     justifyLeftMenuItem.addActionListener(new ActionListener()
464     {
465       @Override
466       public void actionPerformed(ActionEvent e)
467       {
468         justifyLeftMenuItem_actionPerformed(e);
469       }
470     });
471     JMenuItem justifyRightMenuItem = new JMenuItem(
472             MessageManager.getString("action.right_justify_alignment"));
473     justifyRightMenuItem.addActionListener(new ActionListener()
474     {
475       @Override
476       public void actionPerformed(ActionEvent e)
477       {
478         justifyRightMenuItem_actionPerformed(e);
479       }
480     });
481     viewBoxesMenuItem.setText(MessageManager.getString("action.boxes"));
482     viewBoxesMenuItem.setState(true);
483     viewBoxesMenuItem.addActionListener(new ActionListener()
484     {
485       @Override
486       public void actionPerformed(ActionEvent e)
487       {
488         viewBoxesMenuItem_actionPerformed(e);
489       }
490     });
491     viewTextMenuItem.setText(MessageManager.getString("action.text"));
492     viewTextMenuItem.setState(true);
493     viewTextMenuItem.addActionListener(new ActionListener()
494     {
495       @Override
496       public void actionPerformed(ActionEvent e)
497       {
498         viewTextMenuItem_actionPerformed(e);
499       }
500     });
501     showNonconservedMenuItem
502             .setText(MessageManager.getString("label.show_non_conserved"));
503     showNonconservedMenuItem.setState(false);
504     showNonconservedMenuItem.addActionListener(new ActionListener()
505     {
506       @Override
507       public void actionPerformed(ActionEvent e)
508       {
509         showUnconservedMenuItem_actionPerformed(e);
510       }
511     });
512     JMenuItem sortPairwiseMenuItem = new JMenuItem(
513             MessageManager.getString("action.by_pairwise_id"));
514     sortPairwiseMenuItem.addActionListener(new ActionListener()
515     {
516       @Override
517       public void actionPerformed(ActionEvent e)
518       {
519         sortPairwiseMenuItem_actionPerformed(e);
520       }
521     });
522     JMenuItem sortIDMenuItem = new JMenuItem(
523             MessageManager.getString("action.by_id"));
524     sortIDMenuItem.addActionListener(new ActionListener()
525     {
526       @Override
527       public void actionPerformed(ActionEvent e)
528       {
529         sortIDMenuItem_actionPerformed(e);
530       }
531     });
532     JMenuItem sortLengthMenuItem = new JMenuItem(
533             MessageManager.getString("action.by_length"));
534     sortLengthMenuItem.addActionListener(new ActionListener()
535     {
536       @Override
537       public void actionPerformed(ActionEvent e)
538       {
539         sortLengthMenuItem_actionPerformed(e);
540       }
541     });
542     JMenuItem sortGroupMenuItem = new JMenuItem(
543             MessageManager.getString("action.by_group"));
544     sortGroupMenuItem.addActionListener(new ActionListener()
545     {
546       @Override
547       public void actionPerformed(ActionEvent e)
548       {
549         sortGroupMenuItem_actionPerformed(e);
550       }
551     });
552   
553     JMenuItem removeRedundancyMenuItem = new JMenuItem(
554             MessageManager.getString("action.remove_redundancy"));
555     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_D,
556             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
557     al = new ActionListener()
558     {
559       @Override
560       public void actionPerformed(ActionEvent e)
561       {
562         removeRedundancyMenuItem_actionPerformed(e);
563       }
564     };
565     addMenuActionAndAccelerator(keyStroke, removeRedundancyMenuItem, al);
566   
567     JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(
568             MessageManager.getString("action.pairwise_alignment"));
569     pairwiseAlignmentMenuItem.addActionListener(new ActionListener()
570     {
571       @Override
572       public void actionPerformed(ActionEvent e)
573       {
574         pairwiseAlignmentMenuItem_actionPerformed(e);
575       }
576     });
577   
578     this.getContentPane().setLayout(new BorderLayout());
579     alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11));
580     statusBar.setBackground(Color.white);
581     statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
582     statusBar.setBorder(BorderFactory.createLineBorder(Color.black));
583     statusBar.setText(MessageManager.getString("label.status_bar"));
584
585     outputTextboxMenu
586             .setText(MessageManager.getString("label.out_to_textbox"));
587
588
589     annotationPanelMenuItem.setActionCommand("");
590     annotationPanelMenuItem
591             .setText(MessageManager.getString("label.show_annotations"));
592     annotationPanelMenuItem
593             .setState(Cache.getDefault("SHOW_ANNOTATIONS", true));
594     annotationPanelMenuItem.addActionListener(new ActionListener()
595     {
596       @Override
597       public void actionPerformed(ActionEvent e)
598       {
599         annotationPanelMenuItem_actionPerformed(e);
600       }
601     });
602     showAllAlAnnotations.setText(
603             MessageManager.getString("label.show_all_al_annotations"));
604     final boolean isAnnotationPanelShown = annotationPanelMenuItem
605             .getState();
606     showAllAlAnnotations.setEnabled(isAnnotationPanelShown);
607     showAllAlAnnotations.addActionListener(new ActionListener()
608     {
609       @Override
610       public void actionPerformed(ActionEvent e)
611       {
612         showAllAnnotations_actionPerformed(false, true);
613       }
614     });
615     hideAllAlAnnotations.setText(
616             MessageManager.getString("label.hide_all_al_annotations"));
617     hideAllAlAnnotations.setEnabled(isAnnotationPanelShown);
618     hideAllAlAnnotations.addActionListener(new ActionListener()
619     {
620       @Override
621       public void actionPerformed(ActionEvent e)
622       {
623         hideAllAnnotations_actionPerformed(false, true);
624       }
625     });
626     showAllSeqAnnotations.setText(
627             MessageManager.getString("label.show_all_seq_annotations"));
628     showAllSeqAnnotations.setEnabled(isAnnotationPanelShown);
629     showAllSeqAnnotations.addActionListener(new ActionListener()
630     {
631       @Override
632       public void actionPerformed(ActionEvent e)
633       {
634         showAllAnnotations_actionPerformed(true, false);
635       }
636     });
637     hideAllSeqAnnotations.setText(
638             MessageManager.getString("label.hide_all_seq_annotations"));
639     hideAllSeqAnnotations.setEnabled(isAnnotationPanelShown);
640     hideAllSeqAnnotations.addActionListener(new ActionListener()
641     {
642       @Override
643       public void actionPerformed(ActionEvent e)
644       {
645         hideAllAnnotations_actionPerformed(true, false);
646       }
647     });
648     SequenceAnnotationOrder sortAnnotationsBy = SequenceAnnotationOrder
649             .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
650                     SequenceAnnotationOrder.NONE.name()));
651     final JCheckBoxMenuItem sortAnnBySequence = new JCheckBoxMenuItem(
652             MessageManager.getString("label.sort_annotations_by_sequence"));
653     final JCheckBoxMenuItem sortAnnByLabel = new JCheckBoxMenuItem(
654             MessageManager.getString("label.sort_annotations_by_label"));
655
656
657     sortAnnBySequence.setSelected(
658             sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
659     sortAnnBySequence.addActionListener(new ActionListener()
660     {
661       @Override
662       public void actionPerformed(ActionEvent e)
663       {
664         boolean newState = sortAnnBySequence.getState();
665         sortAnnByLabel.setSelected(false);
666         setAnnotationSortOrder(
667                 newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL
668                         : SequenceAnnotationOrder.NONE);
669         sortAnnotations_actionPerformed();
670       }
671     });
672     sortAnnByLabel.setSelected(
673             sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
674     sortAnnByLabel.addActionListener(new ActionListener()
675     {
676       @Override
677       public void actionPerformed(ActionEvent e)
678       {
679         boolean newState = sortAnnByLabel.getState();
680         sortAnnBySequence.setSelected(false);
681         setAnnotationSortOrder(
682                 newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE
683                         : SequenceAnnotationOrder.NONE);
684         sortAnnotations_actionPerformed();
685       }
686     });
687     colourTextMenuItem = new JCheckBoxMenuItem(
688             MessageManager.getString("label.colour_text"));
689     colourTextMenuItem.addActionListener(new ActionListener()
690     {
691       @Override
692       public void actionPerformed(ActionEvent e)
693       {
694         colourTextMenuItem_actionPerformed(e);
695       }
696     });
697   
698     JMenuItem htmlMenuItem = new JMenuItem(
699             MessageManager.getString("label.html"));
700     htmlMenuItem.addActionListener(new ActionListener()
701     {
702       @Override
703       public void actionPerformed(ActionEvent e)
704       {
705         htmlMenuItem_actionPerformed(e);
706       }
707     });
708   
709     JMenuItem createBioJS = new JMenuItem(
710             MessageManager.getString("label.biojs_html_export"));
711     createBioJS.addActionListener(new java.awt.event.ActionListener()
712     {
713       @Override
714       public void actionPerformed(ActionEvent e)
715       {
716         bioJSMenuItem_actionPerformed(e);
717       }
718     });
719   
720     JMenuItem overviewMenuItem = new JMenuItem(
721             MessageManager.getString("label.overview_window"));
722     overviewMenuItem.addActionListener(new ActionListener()
723     {
724       @Override
725       public void actionPerformed(ActionEvent e)
726       {
727         overviewMenuItem_actionPerformed(e);
728       }
729     });
730   
731     undoMenuItem.setEnabled(false);
732     undoMenuItem.setText(MessageManager.getString("action.undo"));
733     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z,
734             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
735     al = new ActionListener()
736     {
737       @Override
738       public void actionPerformed(ActionEvent e)
739       {
740         undoMenuItem_actionPerformed(e);
741       }
742     };
743     addMenuActionAndAccelerator(keyStroke, undoMenuItem, al);
744   
745     redoMenuItem.setEnabled(false);
746     redoMenuItem.setText(MessageManager.getString("action.redo"));
747     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y,
748             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
749     al = new ActionListener()
750     {
751       @Override
752       public void actionPerformed(ActionEvent e)
753       {
754         redoMenuItem_actionPerformed(e);
755       }
756     };
757     addMenuActionAndAccelerator(keyStroke, redoMenuItem, al);
758   
759     wrapMenuItem.setText(MessageManager.getString("label.wrap"));
760     wrapMenuItem.addActionListener(new ActionListener()
761     {
762       @Override
763       public void actionPerformed(ActionEvent e)
764       {
765         wrapMenuItem_actionPerformed(e);
766       }
767     });
768   
769     JMenuItem printMenuItem = new JMenuItem(
770             MessageManager.getString("action.print"));
771     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P,
772             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
773     al = new ActionListener()
774     {
775       @Override
776       public void actionPerformed(ActionEvent e)
777       {
778         printMenuItem_actionPerformed(e);
779       }
780     };
781     addMenuActionAndAccelerator(keyStroke, printMenuItem, al);
782   
783     renderGapsMenuItem
784             .setText(MessageManager.getString("action.show_gaps"));
785     renderGapsMenuItem.setState(true);
786     renderGapsMenuItem.addActionListener(new ActionListener()
787     {
788       @Override
789       public void actionPerformed(ActionEvent e)
790       {
791         renderGapsMenuItem_actionPerformed(e);
792       }
793     });
794   
795     JMenuItem findMenuItem = new JMenuItem(
796             MessageManager.getString("action.find"));
797     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F,
798             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
799     findMenuItem.setToolTipText(JvSwingUtils.wrapTooltip(true,
800             MessageManager.getString("label.find_tip")));
801     al = new ActionListener()
802     {
803       @Override
804       public void actionPerformed(ActionEvent e)
805       {
806         findMenuItem_actionPerformed(e);
807       }
808     };
809     addMenuActionAndAccelerator(keyStroke, findMenuItem, al);
810
811     showSeqFeatures.setText(
812             MessageManager.getString("label.show_sequence_features"));
813
814     showSeqFeatures.addActionListener(new ActionListener()
815     {
816       @Override
817       public void actionPerformed(ActionEvent actionEvent)
818       {
819         showSeqFeatures_actionPerformed(actionEvent);
820       }
821     });
822     /*
823      * showSeqFeaturesHeight.setText("Vary Sequence Feature Height");
824      * showSeqFeaturesHeight.addActionListener(new ActionListener() { public
825      * void actionPerformed(ActionEvent actionEvent) {
826      * showSeqFeaturesHeight_actionPerformed(actionEvent); } });
827      */
828     showDbRefsMenuitem
829             .setText(MessageManager.getString("label.show_database_refs"));
830     showDbRefsMenuitem.addActionListener(new ActionListener()
831     {
832   
833       @Override
834       public void actionPerformed(ActionEvent e)
835       {
836         showDbRefs_actionPerformed(e);
837       }
838   
839     });
840     showNpFeatsMenuitem.setText(
841             MessageManager.getString("label.show_non_positional_features"));
842     showNpFeatsMenuitem.addActionListener(new ActionListener()
843     {
844   
845       @Override
846       public void actionPerformed(ActionEvent e)
847       {
848         showNpFeats_actionPerformed(e);
849       }
850   
851     });
852     showGroupConservation
853             .setText(MessageManager.getString("label.group_conservation"));
854     showGroupConservation.addActionListener(new ActionListener()
855     {
856   
857       @Override
858       public void actionPerformed(ActionEvent e)
859       {
860         showGroupConservation_actionPerformed(e);
861       }
862   
863     });
864
865     showGroupConsensus
866             .setText(MessageManager.getString("label.group_consensus"));
867     showGroupConsensus.addActionListener(new ActionListener()
868     {
869   
870       @Override
871       public void actionPerformed(ActionEvent e)
872       {
873         showGroupConsensus_actionPerformed(e);
874       }
875   
876     });
877     showConsensusHistogram.setText(
878             MessageManager.getString("label.show_consensus_histogram"));
879     showConsensusHistogram.addActionListener(new ActionListener()
880     {
881   
882       @Override
883       public void actionPerformed(ActionEvent e)
884       {
885         showConsensusHistogram_actionPerformed(e);
886       }
887   
888     });
889     showSequenceLogo
890             .setText(MessageManager.getString("label.show_consensus_logo"));
891     showSequenceLogo.addActionListener(new ActionListener()
892     {
893   
894       @Override
895       public void actionPerformed(ActionEvent e)
896       {
897         showSequenceLogo_actionPerformed(e);
898       }
899   
900     });
901     normaliseSequenceLogo
902             .setText(MessageManager.getString("label.norm_consensus_logo"));
903     normaliseSequenceLogo.addActionListener(new ActionListener()
904     {
905   
906       @Override
907       public void actionPerformed(ActionEvent e)
908       {
909         normaliseSequenceLogo_actionPerformed(e);
910       }
911   
912     });
913     applyAutoAnnotationSettings
914             .setText(MessageManager.getString("label.apply_all_groups"));
915     applyAutoAnnotationSettings.setState(false);
916     applyAutoAnnotationSettings.setVisible(true);
917     applyAutoAnnotationSettings.addActionListener(new ActionListener()
918     {
919       @Override
920       public void actionPerformed(ActionEvent e)
921       {
922         applyAutoAnnotationSettings_actionPerformed(e);
923       }
924     });
925   
926     ButtonGroup buttonGroup = new ButtonGroup();
927     final JRadioButtonMenuItem showAutoFirst = new JRadioButtonMenuItem(
928             MessageManager.getString("label.show_first"));
929     final JRadioButtonMenuItem showAutoLast = new JRadioButtonMenuItem(
930             MessageManager.getString("label.show_last"));
931     buttonGroup.add(showAutoFirst);
932     buttonGroup.add(showAutoLast);
933     final boolean autoFirst = Cache
934             .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
935     showAutoFirst.setSelected(autoFirst);
936     setShowAutoCalculatedAbove(autoFirst);
937     showAutoFirst.addActionListener(new ActionListener()
938     {
939       @Override
940       public void actionPerformed(ActionEvent e)
941       {
942         setShowAutoCalculatedAbove(showAutoFirst.isSelected());
943         sortAnnotations_actionPerformed();
944       }
945     });
946     showAutoLast.setSelected(!showAutoFirst.isSelected());
947     showAutoLast.addActionListener(new ActionListener()
948     {
949       @Override
950       public void actionPerformed(ActionEvent e)
951       {
952         setShowAutoCalculatedAbove(!showAutoLast.isSelected());
953         sortAnnotations_actionPerformed();
954       }
955     });
956   
957     JMenuItem deleteGroups = new JMenuItem(
958             MessageManager.getString("action.undefine_groups"));
959     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_U,
960             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
961     al = new ActionListener()
962     {
963       @Override
964       public void actionPerformed(ActionEvent e)
965       {
966         deleteGroups_actionPerformed(e);
967       }
968     };
969     addMenuActionAndAccelerator(keyStroke, deleteGroups, al);
970   
971     JMenuItem annotationColumn = new JMenuItem(
972             MessageManager.getString("action.select_by_annotation"));
973     annotationColumn.addActionListener(new ActionListener()
974     {
975       @Override
976       public void actionPerformed(ActionEvent e)
977       {
978         annotationColumn_actionPerformed(e);
979       }
980     });
981   
982     JMenuItem createGroup = new JMenuItem(
983             MessageManager.getString("action.create_group"));
984     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
985             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
986     al = new ActionListener()
987     {
988       @Override
989       public void actionPerformed(ActionEvent e)
990       {
991         createGroup_actionPerformed(e);
992       }
993     };
994     addMenuActionAndAccelerator(keyStroke, createGroup, al);
995   
996     JMenuItem unGroup = new JMenuItem(
997             MessageManager.getString("action.remove_group"));
998     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G,
999             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
1000                     | KeyEvent.SHIFT_MASK,
1001             false);
1002     al = new ActionListener()
1003     {
1004       @Override
1005       public void actionPerformed(ActionEvent e)
1006       {
1007         unGroup_actionPerformed(e);
1008       }
1009     };
1010     addMenuActionAndAccelerator(keyStroke, unGroup, al);
1011   
1012     copy.setText(MessageManager.getString("action.copy"));
1013     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_C,
1014             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
1015
1016     al = new ActionListener()
1017     {
1018       @Override
1019       public void actionPerformed(ActionEvent e)
1020       {
1021         copy_actionPerformed(e);
1022       }
1023     };
1024     addMenuActionAndAccelerator(keyStroke, copy, al);
1025   
1026     cut.setText(MessageManager.getString("action.cut"));
1027     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X,
1028             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
1029     al = new ActionListener()
1030     {
1031       @Override
1032       public void actionPerformed(ActionEvent e)
1033       {
1034         cut_actionPerformed(e);
1035       }
1036     };
1037     addMenuActionAndAccelerator(keyStroke, cut, al);
1038   
1039     JMenuItem delete = new JMenuItem(
1040             MessageManager.getString("action.delete"));
1041     delete.addActionListener(new ActionListener()
1042     {
1043       @Override
1044       public void actionPerformed(ActionEvent e)
1045       {
1046         delete_actionPerformed(e);
1047       }
1048     });
1049   
1050     pasteMenu.setText(MessageManager.getString("action.paste"));
1051     JMenuItem pasteNew = new JMenuItem(
1052             MessageManager.getString("label.to_new_alignment"));
1053     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
1054             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
1055                     | KeyEvent.SHIFT_MASK,
1056             false);
1057     al = new ActionListener()
1058     {
1059       @Override
1060       public void actionPerformed(ActionEvent e)
1061       {
1062         try
1063         {
1064           pasteNew_actionPerformed(e);
1065         } catch (IOException | InterruptedException e1)
1066         {
1067           // TODO Auto-generated catch block
1068           e1.printStackTrace();
1069         }
1070       }
1071     };
1072     addMenuActionAndAccelerator(keyStroke, pasteNew, al);
1073   
1074     JMenuItem pasteThis = new JMenuItem(
1075             MessageManager.getString("label.to_this_alignment"));
1076     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V,
1077             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
1078     al = new ActionListener()
1079     {
1080       @Override
1081       public void actionPerformed(ActionEvent e)
1082       {
1083         try
1084         {
1085           pasteThis_actionPerformed(e);
1086         } catch (IOException | InterruptedException e1)
1087         {
1088           // TODO Auto-generated catch block
1089           e1.printStackTrace();
1090         }
1091       }
1092     };
1093     addMenuActionAndAccelerator(keyStroke, pasteThis, al);
1094   
1095     JMenuItem createPNG = new JMenuItem("PNG");
1096     createPNG.addActionListener(new ActionListener()
1097     {
1098       @Override
1099       public void actionPerformed(ActionEvent e)
1100       {
1101         createPNG(null);
1102       }
1103     });
1104     createPNG.setActionCommand(
1105             MessageManager.getString("label.save_png_image"));
1106     JMenuItem font = new JMenuItem(MessageManager.getString("action.font"));
1107     font.addActionListener(new ActionListener()
1108     {
1109       @Override
1110       public void actionPerformed(ActionEvent e)
1111       {
1112         font_actionPerformed(e);
1113       }
1114     });
1115     seqLimits.setText(
1116             MessageManager.getString("label.show_sequence_limits"));
1117     seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true));
1118     seqLimits.addActionListener(new ActionListener()
1119     {
1120       @Override
1121       public void actionPerformed(ActionEvent e)
1122       {
1123         seqLimit_actionPerformed(e);
1124       }
1125     });
1126     JMenuItem epsFile = new JMenuItem("EPS");
1127     epsFile.addActionListener(new ActionListener()
1128     {
1129       @Override
1130       public void actionPerformed(ActionEvent e)
1131       {
1132         createEPS(null);
1133       }
1134     });
1135   
1136     JMenuItem createSVG = new JMenuItem("SVG");
1137     createSVG.addActionListener(new ActionListener()
1138     {
1139       @Override
1140       public void actionPerformed(ActionEvent e)
1141       {
1142         createSVG(null);
1143       }
1144     });
1145   
1146     JMenuItem loadTreeMenuItem = new JMenuItem(
1147             MessageManager.getString("label.load_associated_tree"));
1148     loadTreeMenuItem.setActionCommand(
1149             MessageManager.getString("label.load_tree_for_sequence_set"));
1150     loadTreeMenuItem.addActionListener(new ActionListener()
1151     {
1152       @Override
1153       public void actionPerformed(ActionEvent e)
1154       {
1155         loadTreeMenuItem_actionPerformed(e);
1156       }
1157     });
1158   
1159     scaleAbove.setVisible(false);
1160     scaleAbove.setText(MessageManager.getString("action.scale_above"));
1161     scaleAbove.addActionListener(new ActionListener()
1162     {
1163       @Override
1164       public void actionPerformed(ActionEvent e)
1165       {
1166         scaleAbove_actionPerformed(e);
1167       }
1168     });
1169     scaleLeft.setVisible(false);
1170     scaleLeft.setSelected(true);
1171     scaleLeft.setText(MessageManager.getString("action.scale_left"));
1172     scaleLeft.addActionListener(new ActionListener()
1173     {
1174       @Override
1175       public void actionPerformed(ActionEvent e)
1176       {
1177         scaleLeft_actionPerformed(e);
1178       }
1179     });
1180     scaleRight.setVisible(false);
1181     scaleRight.setSelected(true);
1182     scaleRight.setText(MessageManager.getString("action.scale_right"));
1183     scaleRight.addActionListener(new ActionListener()
1184     {
1185       @Override
1186       public void actionPerformed(ActionEvent e)
1187       {
1188         scaleRight_actionPerformed(e);
1189       }
1190     });
1191     centreColumnLabelsMenuItem.setVisible(true);
1192     centreColumnLabelsMenuItem.setState(false);
1193     centreColumnLabelsMenuItem.setText(
1194             MessageManager.getString("label.centre_column_labels"));
1195     centreColumnLabelsMenuItem.addActionListener(new ActionListener()
1196     {
1197       @Override
1198       public void actionPerformed(ActionEvent e)
1199       {
1200         centreColumnLabels_actionPerformed(e);
1201       }
1202     });
1203     followHighlightMenuItem.setVisible(true);
1204     followHighlightMenuItem.setState(true);
1205     followHighlightMenuItem
1206             .setText(MessageManager.getString("label.automatic_scrolling"));
1207     followHighlightMenuItem.addActionListener(new ActionListener()
1208     {
1209   
1210       @Override
1211       public void actionPerformed(ActionEvent e)
1212       {
1213         followHighlight_actionPerformed();
1214       }
1215   
1216     });
1217   
1218     sortByTreeMenu
1219             .setText(MessageManager.getString("action.by_tree_order"));
1220     sort.setText(MessageManager.getString("action.sort"));
1221     sort.addMenuListener(new MenuListener()
1222     {
1223       @Override
1224       public void menuSelected(MenuEvent e)
1225       {
1226         buildTreeSortMenu();
1227       }
1228   
1229       @Override
1230       public void menuDeselected(MenuEvent e)
1231       {
1232       }
1233   
1234       @Override
1235       public void menuCanceled(MenuEvent e)
1236       {
1237       }
1238     });
1239     sortByAnnotScore
1240             .setText(MessageManager.getString("label.sort_by_score"));
1241     sort.add(sortByAnnotScore);
1242     sort.addMenuListener(new javax.swing.event.MenuListener()
1243     {
1244   
1245       @Override
1246       public void menuCanceled(MenuEvent e)
1247       {
1248       }
1249   
1250       @Override
1251       public void menuDeselected(MenuEvent e)
1252       {
1253       }
1254   
1255       @Override
1256       public void menuSelected(MenuEvent e)
1257       {
1258         buildSortByAnnotationScoresMenu();
1259       }
1260     });
1261     sortByAnnotScore.setVisible(false);
1262
1263     calculateTree
1264             .setText(MessageManager.getString("action.calculate_tree_pca"));
1265
1266     padGapsMenuitem.setText(MessageManager.getString("label.pad_gaps"));
1267     padGapsMenuitem
1268             .setState(jalview.bin.Cache.getDefault("PAD_GAPS", false));
1269     padGapsMenuitem.addActionListener(new ActionListener()
1270     {
1271       @Override
1272       public void actionPerformed(ActionEvent e)
1273       {
1274         padGapsMenuitem_actionPerformed(e);
1275       }
1276     });
1277     JMenuItem vamsasStore = new JMenuItem(
1278             MessageManager.getString("label.vamsas_store"));
1279     vamsasStore.setVisible(false);
1280     vamsasStore.addActionListener(new ActionListener()
1281     {
1282       @Override
1283       public void actionPerformed(ActionEvent e)
1284       {
1285         vamsasStore_actionPerformed(e);
1286       }
1287     });
1288     showTranslation
1289             .setText(MessageManager.getString("label.translate_cDNA"));
1290     showTranslation.addActionListener(new ActionListener()
1291     {
1292       @Override
1293       public void actionPerformed(ActionEvent e)
1294       {
1295         showTranslation_actionPerformed(e);
1296       }
1297     });
1298     showReverse.setText(MessageManager.getString("label.reverse"));
1299     showReverse.addActionListener(new ActionListener()
1300     {
1301       @Override
1302       public void actionPerformed(ActionEvent e)
1303       {
1304         showReverse_actionPerformed(false);
1305       }
1306     });
1307     showReverseComplement
1308             .setText(MessageManager.getString("label.reverse_complement"));
1309     showReverseComplement.addActionListener(new ActionListener()
1310     {
1311       @Override
1312       public void actionPerformed(ActionEvent e)
1313       {
1314         showReverse_actionPerformed(true);
1315       }
1316     });
1317   
1318     JMenuItem extractScores = new JMenuItem(
1319             MessageManager.getString("label.extract_scores"));
1320     extractScores.addActionListener(new ActionListener()
1321     {
1322       @Override
1323       public void actionPerformed(ActionEvent e)
1324       {
1325         extractScores_actionPerformed(e);
1326       }
1327     });
1328     extractScores.setVisible(true);
1329     // JBPNote: TODO: make gui for regex based score extraction
1330   
1331     // for show products actions see AlignFrame.canShowProducts
1332     showProducts.setText(MessageManager.getString("label.get_cross_refs"));
1333   
1334     runGroovy.setText(MessageManager.getString("label.run_groovy"));
1335     runGroovy.setToolTipText(
1336             MessageManager.getString("label.run_groovy_tip"));
1337     runGroovy.addActionListener(new ActionListener()
1338     {
1339       @Override
1340       public void actionPerformed(ActionEvent e)
1341       {
1342         runGroovy_actionPerformed();
1343       }
1344     });
1345   
1346     JMenuItem openFeatureSettings = new JMenuItem(
1347             MessageManager.getString("action.feature_settings"));
1348     openFeatureSettings.addActionListener(new ActionListener()
1349     {
1350       @Override
1351       public void actionPerformed(ActionEvent e)
1352       {
1353         featureSettings_actionPerformed(e);
1354       }
1355     });
1356     JMenuItem fetchSequence = new JMenuItem(
1357             MessageManager.getString("label.fetch_sequences"));
1358     fetchSequence.addActionListener(new ActionListener()
1359     {
1360       @Override
1361       public void actionPerformed(ActionEvent e)
1362       {
1363         fetchSequence_actionPerformed(e);
1364       }
1365     });
1366   
1367     JMenuItem associatedData = new JMenuItem(
1368             MessageManager.getString("label.load_features_annotations"));
1369     associatedData.addActionListener(new ActionListener()
1370     {
1371       @Override
1372       public void actionPerformed(ActionEvent e)
1373       {
1374         try
1375         {
1376           associatedData_actionPerformed(e);
1377         } catch (IOException | InterruptedException e1)
1378         {
1379           // TODO Auto-generated catch block
1380           e1.printStackTrace();
1381         }
1382       }
1383     });
1384     autoCalculate.setText(
1385             MessageManager.getString("label.autocalculate_consensus"));
1386     autoCalculate.setState(
1387             jalview.bin.Cache.getDefault("AUTO_CALC_CONSENSUS", true));
1388     autoCalculate.addActionListener(new ActionListener()
1389     {
1390       @Override
1391       public void actionPerformed(ActionEvent e)
1392       {
1393         autoCalculate_actionPerformed(e);
1394       }
1395     });
1396     sortByTree.setText(
1397             MessageManager.getString("label.sort_alignment_new_tree"));
1398     sortByTree.setToolTipText("<html>" + MessageManager.getString(
1399             "label.enable_automatically_sort_alignment_when_open_new_tree"));
1400     sortByTree
1401             .setState(jalview.bin.Cache.getDefault("SORT_BY_TREE", false));
1402     sortByTree.addActionListener(new ActionListener()
1403     {
1404       @Override
1405       public void actionPerformed(ActionEvent e)
1406       {
1407         sortByTreeOption_actionPerformed(e);
1408       }
1409     });
1410
1411     listenToViewSelections.setText(
1412             MessageManager.getString("label.listen_for_selections"));
1413     listenToViewSelections
1414             .setToolTipText("<html>" + MessageManager.getString(
1415                     "label.selections_mirror_selections_made_same_sequences_other_views"));
1416     listenToViewSelections.setState(false);
1417     listenToViewSelections.addActionListener(new ActionListener()
1418     {
1419       @Override
1420       public void actionPerformed(ActionEvent e)
1421       {
1422         listenToViewSelections_actionPerformed(e);
1423       }
1424     });
1425   
1426     JMenu addSequenceMenu = new JMenu(
1427             MessageManager.getString("label.add_sequences"));
1428     JMenuItem addFromFile = new JMenuItem(
1429             MessageManager.getString("label.from_file"));
1430     addFromFile.addActionListener(new ActionListener()
1431     {
1432       @Override
1433       public void actionPerformed(ActionEvent e)
1434       {
1435         addFromFile_actionPerformed(e);
1436       }
1437     });
1438     JMenuItem addFromText = new JMenuItem(
1439             MessageManager.getString("label.from_textbox"));
1440     addFromText.addActionListener(new ActionListener()
1441     {
1442       @Override
1443       public void actionPerformed(ActionEvent e)
1444       {
1445         addFromText_actionPerformed(e);
1446       }
1447     });
1448     JMenuItem addFromURL = new JMenuItem(
1449             MessageManager.getString("label.from_url"));
1450     addFromURL.addActionListener(new ActionListener()
1451     {
1452       @Override
1453       public void actionPerformed(ActionEvent e)
1454       {
1455         addFromURL_actionPerformed(e);
1456       }
1457     });
1458     JMenuItem exportFeatures = new JMenuItem(
1459             MessageManager.getString("label.export_features"));
1460     exportFeatures.addActionListener(new ActionListener()
1461     {
1462       @Override
1463       public void actionPerformed(ActionEvent e)
1464       {
1465         exportFeatures_actionPerformed(e);
1466       }
1467     });
1468     JMenuItem exportAnnotations = new JMenuItem(
1469             MessageManager.getString("label.export_annotations"));
1470     exportAnnotations.addActionListener(new ActionListener()
1471     {
1472       @Override
1473       public void actionPerformed(ActionEvent e)
1474       {
1475         exportAnnotations_actionPerformed(e);
1476       }
1477     });
1478     statusPanel.setLayout(new GridLayout());
1479     JMenuItem showAllSeqs = new JMenuItem(
1480             MessageManager.getString("label.all_sequences"));
1481     showAllSeqs.setToolTipText(
1482             MessageManager.getString("label.toggle_sequence_visibility"));
1483     showAllSeqs.addActionListener(new ActionListener()
1484     {
1485       @Override
1486       public void actionPerformed(ActionEvent e)
1487       {
1488         showAllSeqs_actionPerformed(e);
1489       }
1490     });
1491     JMenuItem showAllColumns = new JMenuItem(
1492             MessageManager.getString("label.all_columns"));
1493     showAllColumns.setToolTipText(
1494             MessageManager.getString("label.toggle_columns_visibility"));
1495     showAllColumns.addActionListener(new ActionListener()
1496     {
1497       @Override
1498       public void actionPerformed(ActionEvent e)
1499       {
1500         showAllColumns_actionPerformed(e);
1501       }
1502     });
1503     JMenu hideMenu = new JMenu(MessageManager.getString("action.hide"));
1504     JMenuItem hideSelSequences = new JMenuItem(
1505             MessageManager.getString("label.selected_sequences"));
1506     hideSelSequences.setToolTipText(
1507             MessageManager.getString("label.toggle_sequence_visibility"));
1508     hideSelSequences.addActionListener(new ActionListener()
1509     {
1510       @Override
1511       public void actionPerformed(ActionEvent e)
1512       {
1513         hideSelSequences_actionPerformed(e);
1514       }
1515     });
1516     JMenuItem hideSelColumns = new JMenuItem(
1517             MessageManager.getString("label.selected_columns"));
1518     hideSelColumns.setToolTipText(
1519             MessageManager.getString("label.toggle_columns_visibility"));
1520     hideSelColumns.addActionListener(new ActionListener()
1521     {
1522       @Override
1523       public void actionPerformed(ActionEvent e)
1524       {
1525         hideSelColumns_actionPerformed(e);
1526       }
1527     });
1528     JMenuItem hideAllSelection = new JMenuItem(
1529             MessageManager.getString("label.selected_region"));
1530     hideAllSelection.addActionListener(new ActionListener()
1531     {
1532       @Override
1533       public void actionPerformed(ActionEvent e)
1534       {
1535         hideAllSelection_actionPerformed(e);
1536       }
1537     });
1538     // TODO: should be hidden if no selection exists.
1539     JMenuItem hideAllButSelection = new JMenuItem(
1540             MessageManager.getString("label.all_but_selected_region"));
1541     hideAllButSelection.addActionListener(new ActionListener()
1542     {
1543       @Override
1544       public void actionPerformed(ActionEvent e)
1545       {
1546         hideAllButSelection_actionPerformed(e);
1547       }
1548     });
1549     JMenuItem showAllhidden = new JMenuItem(
1550             MessageManager.getString("label.all_sequences_columns"));
1551     showAllhidden.setToolTipText(MessageManager
1552             .getString("label.toggles_visibility_hidden_selected_regions"));
1553     showAllhidden.addActionListener(new ActionListener()
1554     {
1555       @Override
1556       public void actionPerformed(ActionEvent e)
1557       {
1558         showAllhidden_actionPerformed(e);
1559       }
1560     });
1561     hiddenMarkers.setText(
1562             MessageManager.getString("action.show_hidden_markers"));
1563     hiddenMarkers.addActionListener(new ActionListener()
1564     {
1565       @Override
1566       public void actionPerformed(ActionEvent e)
1567       {
1568         hiddenMarkers_actionPerformed(e);
1569       }
1570     });
1571   
1572     JMenuItem invertColSel = new JMenuItem(
1573             MessageManager.getString("action.invert_column_selection"));
1574     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_I,
1575             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
1576                     | KeyEvent.ALT_MASK,
1577             false);
1578     al = new ActionListener()
1579     {
1580       @Override
1581       public void actionPerformed(ActionEvent e)
1582       {
1583         invertColSel_actionPerformed(e);
1584       }
1585     };
1586     addMenuActionAndAccelerator(keyStroke, invertColSel, al);
1587   
1588     showComplementMenuItem.setVisible(false);
1589     showComplementMenuItem.addActionListener(new ActionListener()
1590     {
1591       @Override
1592       public void actionPerformed(ActionEvent e)
1593       {
1594         showComplement_actionPerformed(showComplementMenuItem.getState());
1595       }
1596     });
1597   
1598     tabbedPane.addChangeListener(new javax.swing.event.ChangeListener()
1599     {
1600       @Override
1601       public void stateChanged(ChangeEvent evt)
1602       {
1603         JTabbedPane pane = (JTabbedPane) evt.getSource();
1604         int sel = pane.getSelectedIndex();
1605         tabSelectionChanged(sel);
1606       }
1607     });
1608     tabbedPane.addMouseListener(new MouseAdapter()
1609     {
1610       @Override
1611       public void mousePressed(MouseEvent e)
1612       {
1613         if (e.isPopupTrigger()) // Mac
1614         {
1615           tabbedPane_mousePressed(e);
1616         }
1617       }
1618   
1619       @Override
1620       public void mouseReleased(MouseEvent e)
1621       {
1622         if (e.isPopupTrigger()) // Windows
1623         {
1624           tabbedPane_mousePressed(e);
1625         }
1626       }
1627     });
1628     tabbedPane.addFocusListener(new FocusAdapter()
1629     {
1630       @Override
1631       public void focusGained(FocusEvent e)
1632       {
1633         tabbedPane_focusGained(e);
1634       }
1635     });
1636   
1637     JMenuItem save = new JMenuItem(MessageManager.getString("action.save"));
1638     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S,
1639             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
1640     al = new ActionListener()
1641     {
1642       @Override
1643       public void actionPerformed(ActionEvent e)
1644       {
1645         save_actionPerformed(e);
1646       }
1647     };
1648     addMenuActionAndAccelerator(keyStroke, save, al);
1649   
1650     reload.setEnabled(false);
1651     reload.setText(MessageManager.getString("action.reload"));
1652     reload.addActionListener(new ActionListener()
1653     {
1654       @Override
1655       public void actionPerformed(ActionEvent e)
1656       {
1657         reload_actionPerformed(e);
1658       }
1659     });
1660   
1661     JMenuItem newView = new JMenuItem(
1662             MessageManager.getString("action.new_view"));
1663     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_T,
1664             Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
1665     al = new ActionListener()
1666     {
1667       @Override
1668       public void actionPerformed(ActionEvent e)
1669       {
1670         newView_actionPerformed(e);
1671       }
1672     };
1673     addMenuActionAndAccelerator(keyStroke, newView, al);
1674   
1675     tabbedPane.setToolTipText("<html><i>"
1676             + MessageManager.getString("label.rename_tab_eXpand_reGroup")
1677             + "</i></html>");
1678   
1679     formatMenu.setText(MessageManager.getString("action.format"));
1680     JMenu selectMenu = new JMenu(MessageManager.getString("action.select"));
1681
1682     idRightAlign.setText(
1683             MessageManager.getString("label.right_align_sequence_id"));
1684     idRightAlign.addActionListener(new ActionListener()
1685     {
1686       @Override
1687       public void actionPerformed(ActionEvent e)
1688       {
1689         idRightAlign_actionPerformed(e);
1690       }
1691     });
1692   
1693     gatherViews.setEnabled(false);
1694     gatherViews.setText(MessageManager.getString("action.gather_views"));
1695     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_G, 0, false);
1696     al = new ActionListener()
1697     {
1698       @Override
1699       public void actionPerformed(ActionEvent e)
1700       {
1701         gatherViews_actionPerformed(e);
1702       }
1703     };
1704     addMenuActionAndAccelerator(keyStroke, gatherViews, al);
1705   
1706     expandViews.setEnabled(false);
1707     expandViews.setText(MessageManager.getString("action.expand_views"));
1708     keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, 0, false);
1709     al = new ActionListener()
1710     {
1711       @Override
1712       public void actionPerformed(ActionEvent e)
1713       {
1714         expandViews_actionPerformed(e);
1715       }
1716     };
1717     addMenuActionAndAccelerator(keyStroke, expandViews, al);
1718   
1719     JMenuItem pageSetup = new JMenuItem(
1720             MessageManager.getString("action.page_setup"));
1721     pageSetup.addActionListener(new ActionListener()
1722     {
1723       @Override
1724       public void actionPerformed(ActionEvent e)
1725       {
1726         pageSetup_actionPerformed(e);
1727       }
1728     });
1729     JMenuItem alignmentProperties = new JMenuItem(
1730             MessageManager.getString("label.alignment_props"));
1731     alignmentProperties.addActionListener(new ActionListener()
1732     {
1733       @Override
1734       public void actionPerformed(ActionEvent actionEvent)
1735       {
1736         alignmentProperties();
1737       }
1738     });
1739     JMenuItem selectHighlighted = new JMenuItem(
1740             MessageManager.getString("action.select_highlighted_columns"));
1741     selectHighlighted.setToolTipText(
1742             MessageManager.getString("tooltip.select_highlighted_columns"));
1743     al = new ActionListener()
1744     {
1745       @Override
1746       public void actionPerformed(ActionEvent actionEvent)
1747       {
1748         selectHighlightedColumns_actionPerformed(actionEvent);
1749       }
1750     };
1751     hmmBuildRun.setText(MessageManager.formatMessage(
1752             "label.action_with_default_settings", "hmmbuild"));
1753     hmmBuildRun.addActionListener(new ActionListener()
1754     {
1755
1756       @Override
1757       public void actionPerformed(ActionEvent e)
1758       {
1759         try
1760         {
1761           hmmBuildRun_actionPerformed(e);
1762         } catch (IOException | InterruptedException e1)
1763         {
1764           // TODO Auto-generated catch block
1765           e1.printStackTrace();
1766         }
1767       }
1768
1769     });
1770     hmmBuildSettings.setText(
1771             MessageManager.getString("label.edit_settings_and_run"));
1772     hmmBuildSettings.addActionListener(new ActionListener()
1773     {
1774
1775       @Override
1776       public void actionPerformed(ActionEvent e)
1777       {
1778         try
1779         {
1780           hmmBuildSettings_actionPerformed(e);
1781         } catch (IOException | InterruptedException e1)
1782         {
1783           // TODO Auto-generated catch block
1784           e1.printStackTrace();
1785         }
1786       }
1787
1788     });
1789     hmmAlignRun.setText(MessageManager.formatMessage(
1790             "label.action_with_default_settings", "hmmalign"));
1791     hmmAlignRun.addActionListener(new ActionListener()
1792     {
1793
1794       @Override
1795       public void actionPerformed(ActionEvent e)
1796       {
1797         try
1798         {
1799           hmmAlignRun_actionPerformed(e);
1800         } catch (IOException | InterruptedException e1)
1801         {
1802           // TODO Auto-generated catch block
1803           e1.printStackTrace();
1804         }
1805       }
1806
1807     });
1808     hmmAlignSettings.setText(
1809             MessageManager.getString("label.edit_settings_and_run"));
1810     hmmAlignSettings.addActionListener(new ActionListener()
1811     {
1812
1813       @Override
1814       public void actionPerformed(ActionEvent e)
1815       {
1816         try
1817         {
1818           hmmAlignSettings_actionPerformed(e);
1819         } catch (IOException | InterruptedException e1)
1820         {
1821           // TODO Auto-generated catch block
1822           e1.printStackTrace();
1823         }
1824       }
1825
1826     });
1827     hmmSearchRun.setText(MessageManager.formatMessage(
1828             "label.action_with_default_settings", "hmmsearch"));
1829     hmmSearchRun.addActionListener(new ActionListener()
1830     {
1831
1832       @Override
1833       public void actionPerformed(ActionEvent e)
1834       {
1835         hmmSearchRun_actionPerformed(e);
1836       }
1837
1838     });
1839     addDatabase.setText(MessageManager.getString("label.add_database"));
1840     addDatabase.addActionListener(new ActionListener()
1841     {
1842
1843       @Override
1844       public void actionPerformed(ActionEvent e)
1845       {
1846         try
1847         {
1848           addDatabase_actionPerformed(e);
1849         } catch (IOException e1)
1850         {
1851           // TODO Auto-generated catch block
1852           e1.printStackTrace();
1853         }
1854       }
1855
1856     });
1857     hmmSearchSettings.setText(
1858             MessageManager.getString("label.edit_settings_and_run"));
1859     hmmSearchSettings.addActionListener(new ActionListener()
1860     {
1861
1862       @Override
1863       public void actionPerformed(ActionEvent e)
1864       {
1865         hmmSearchSettings_actionPerformed(e);
1866       }
1867
1868     });
1869     selectHighlighted.addActionListener(al);
1870     JMenu tooltipSettingsMenu = new JMenu(
1871             MessageManager.getString("label.sequence_id_tooltip"));
1872     JMenu autoAnnMenu = new JMenu(
1873             MessageManager.getString("label.autocalculated_annotation"));
1874   
1875     JMenu exportImageMenu = new JMenu(
1876             MessageManager.getString("label.export_image"));
1877     JMenu fileMenu = new JMenu(MessageManager.getString("action.file"));
1878     alignFrameMenuBar.add(fileMenu);
1879     alignFrameMenuBar.add(editMenu);
1880     alignFrameMenuBar.add(selectMenu);
1881     alignFrameMenuBar.add(viewMenu);
1882     alignFrameMenuBar.add(annotationsMenu);
1883     alignFrameMenuBar.add(formatMenu);
1884     alignFrameMenuBar.add(colourMenu);
1885     alignFrameMenuBar.add(calculateMenu);
1886     alignFrameMenuBar.add(webService);
1887     alignFrameMenuBar.add(hmmerMenu);
1888   
1889     fileMenu.add(fetchSequence);
1890     fileMenu.add(addSequenceMenu);
1891     fileMenu.add(reload);
1892     fileMenu.addSeparator();
1893     fileMenu.add(vamsasStore);
1894     fileMenu.add(save);
1895     fileMenu.add(saveAs);
1896     fileMenu.add(outputTextboxMenu);
1897     fileMenu.add(pageSetup);
1898     fileMenu.add(printMenuItem);
1899     fileMenu.addSeparator();
1900     fileMenu.add(exportImageMenu);
1901     fileMenu.add(exportFeatures);
1902     fileMenu.add(exportAnnotations);
1903     fileMenu.add(loadTreeMenuItem);
1904     fileMenu.add(associatedData);
1905     fileMenu.addSeparator();
1906     fileMenu.add(closeMenuItem);
1907   
1908     pasteMenu.add(pasteNew);
1909     pasteMenu.add(pasteThis);
1910     editMenu.add(undoMenuItem);
1911     editMenu.add(redoMenuItem);
1912     editMenu.add(cut);
1913     editMenu.add(copy);
1914     editMenu.add(pasteMenu);
1915     editMenu.add(delete);
1916     editMenu.addSeparator();
1917     editMenu.add(remove2LeftMenuItem);
1918     editMenu.add(remove2RightMenuItem);
1919     editMenu.add(removeGappedColumnMenuItem);
1920     editMenu.add(removeAllGapsMenuItem);
1921     editMenu.add(removeRedundancyMenuItem);
1922     editMenu.addSeparator();
1923     // dont add these yet in the CVS build - they cannot be undone!
1924     // Excluded from Jalview 2.5 release - undo needs to be implemented.
1925     // editMenu.add(justifyLeftMenuItem);
1926     // editMenu.add(justifyRightMenuItem);
1927     // editMenu.addSeparator();
1928     editMenu.add(padGapsMenuitem);
1929   
1930     showMenu.add(showAllColumns);
1931     showMenu.add(showAllSeqs);
1932     showMenu.add(showAllhidden);
1933     hideMenu.add(hideSelColumns);
1934     hideMenu.add(hideSelSequences);
1935     hideMenu.add(hideAllSelection);
1936     hideMenu.add(hideAllButSelection);
1937     viewMenu.add(newView);
1938     viewMenu.add(expandViews);
1939     viewMenu.add(gatherViews);
1940     viewMenu.addSeparator();
1941     viewMenu.add(showMenu);
1942     viewMenu.add(hideMenu);
1943     viewMenu.add(showComplementMenuItem);
1944     viewMenu.addSeparator();
1945     viewMenu.add(followHighlightMenuItem);
1946     viewMenu.addSeparator();
1947     viewMenu.add(showSeqFeatures);
1948     // viewMenu.add(showSeqFeaturesHeight);
1949     viewMenu.add(openFeatureSettings);
1950     tooltipSettingsMenu.add(showDbRefsMenuitem);
1951     tooltipSettingsMenu.add(showNpFeatsMenuitem);
1952     viewMenu.add(tooltipSettingsMenu);
1953     viewMenu.addSeparator();
1954     viewMenu.add(alignmentProperties);
1955     viewMenu.addSeparator();
1956     viewMenu.add(overviewMenuItem);
1957   
1958     annotationsMenu.add(annotationPanelMenuItem);
1959     annotationsMenu.addSeparator();
1960     annotationsMenu.add(showAllAlAnnotations);
1961     annotationsMenu.add(hideAllAlAnnotations);
1962     annotationsMenu.addSeparator();
1963     annotationsMenu.add(showAllSeqAnnotations);
1964     annotationsMenu.add(hideAllSeqAnnotations);
1965     annotationsMenu.add(sortAnnBySequence);
1966     annotationsMenu.add(sortAnnByLabel);
1967     annotationsMenu.addSeparator();
1968     autoAnnMenu.add(showAutoFirst);
1969     autoAnnMenu.add(showAutoLast);
1970     autoAnnMenu.addSeparator();
1971     autoAnnMenu.add(applyAutoAnnotationSettings);
1972     autoAnnMenu.add(showConsensusHistogram);
1973     autoAnnMenu.add(showSequenceLogo);
1974     autoAnnMenu.add(normaliseSequenceLogo);
1975     autoAnnMenu.addSeparator();
1976     autoAnnMenu.add(showGroupConservation);
1977     autoAnnMenu.add(showGroupConsensus);
1978     annotationsMenu.add(autoAnnMenu);
1979
1980     sort.add(sortIDMenuItem);
1981     sort.add(sortLengthMenuItem);
1982     sort.add(sortGroupMenuItem);
1983     sort.add(sortPairwiseMenuItem);
1984     sort.add(sortByTreeMenu);
1985     calculateMenu.add(sort);
1986     calculateMenu.add(calculateTree);
1987     calculateMenu.addSeparator();
1988     calculateMenu.add(pairwiseAlignmentMenuItem);
1989     calculateMenu.addSeparator();
1990     calculateMenu.add(showTranslation);
1991     calculateMenu.add(showReverse);
1992     calculateMenu.add(showReverseComplement);
1993     calculateMenu.add(showProducts);
1994     calculateMenu.add(autoCalculate);
1995     calculateMenu.add(sortByTree);
1996     calculateMenu.addSeparator();
1997     calculateMenu.add(expandAlignment);
1998     calculateMenu.add(extractScores);
1999     calculateMenu.addSeparator();
2000     calculateMenu.add(runGroovy);
2001   
2002     webServiceNoServices = new JMenuItem(
2003             MessageManager.getString("label.no_services"));
2004     webService.add(webServiceNoServices);
2005     exportImageMenu.add(htmlMenuItem);
2006     exportImageMenu.add(epsFile);
2007     exportImageMenu.add(createPNG);
2008     exportImageMenu.add(createBioJS);
2009     exportImageMenu.add(createSVG);
2010     addSequenceMenu.add(addFromFile);
2011     addSequenceMenu.add(addFromText);
2012     addSequenceMenu.add(addFromURL);
2013     this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
2014     statusPanel.add(statusBar, null);
2015     this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
2016   
2017     formatMenu.add(font);
2018     formatMenu.addSeparator();
2019     formatMenu.add(wrapMenuItem);
2020     formatMenu.add(scaleAbove);
2021     formatMenu.add(scaleLeft);
2022     formatMenu.add(scaleRight);
2023     formatMenu.add(seqLimits);
2024     formatMenu.add(idRightAlign);
2025     formatMenu.add(hiddenMarkers);
2026     formatMenu.add(viewBoxesMenuItem);
2027     formatMenu.add(viewTextMenuItem);
2028     formatMenu.add(colourTextMenuItem);
2029     formatMenu.add(renderGapsMenuItem);
2030     formatMenu.add(centreColumnLabelsMenuItem);
2031     formatMenu.add(showNonconservedMenuItem);
2032     selectMenu.add(findMenuItem);
2033     selectMenu.addSeparator();
2034     selectMenu.add(selectAllSequenceMenuItem);
2035     selectMenu.add(deselectAllSequenceMenuItem);
2036     selectMenu.add(invertSequenceMenuItem);
2037     selectMenu.add(invertColSel);
2038     selectMenu.add(createGroup);
2039     selectMenu.add(unGroup);
2040     selectMenu.add(grpsFromSelection);
2041     selectMenu.add(deleteGroups);
2042     selectMenu.add(annotationColumn);
2043     selectMenu.add(selectHighlighted);
2044     // TODO - determine if the listenToViewSelections button is needed : see bug
2045     // JAL-574
2046     // selectMenu.addSeparator();
2047     // selectMenu.add(listenToViewSelections);
2048   }
2049
2050   public void hmmerMenu_actionPerformed(ActionEvent e)
2051   {
2052
2053   }
2054
2055   /**
2056    * Constructs the entries on the HMMER menu (does not add them to the menu).
2057    */
2058   protected void initHMMERMenu()
2059   {
2060     hmmAlign = new JMenu(MessageManager.getString("label.hmmalign"));
2061     hmmAlignSettings = new JMenuItem(
2062             MessageManager.getString("label.edit_settings_and_run"));
2063     hmmAlignRun = new JMenuItem(MessageManager.formatMessage(
2064             "label.action_with_default_settings", "hmmalign"));
2065     hmmAlign.add(hmmAlignSettings);
2066     hmmAlign.add(hmmAlignRun);
2067     hmmBuild = new JMenu(MessageManager.getString("label.hmmbuild"));
2068     hmmBuildSettings = new JMenuItem(
2069             MessageManager.getString("label.edit_settings_and_run"));
2070     hmmBuildRun = new JMenuItem(MessageManager.formatMessage(
2071             "label.action_with_default_settings", "hmmbuild"));
2072     hmmBuild.add(hmmBuildSettings);
2073     hmmBuild.add(hmmBuildRun);
2074     hmmSearch = new JMenu(MessageManager.getString("label.hmmsearch"));
2075     hmmSearchSettings = new JMenuItem(
2076             MessageManager.getString("label.edit_settings_and_run"));
2077     hmmSearchRun = new JMenuItem(MessageManager.formatMessage(
2078             "label.action_with_default_settings", "hmmsearch"));
2079     addDatabase = new JMenuItem(
2080             MessageManager.getString("label.add_database"));
2081     hmmSearch.add(hmmSearchSettings);
2082     hmmSearch.add(hmmSearchRun);
2083     hmmSearch.add(addDatabase);
2084   }
2085
2086   /**
2087    * Constructs the entries on the Colour menu (but does not add them to the
2088    * menu).
2089    */
2090   protected void initColourMenu()
2091   {
2092     applyToAllGroups = new JCheckBoxMenuItem(
2093             MessageManager.getString("label.apply_colour_to_all_groups"));
2094     applyToAllGroups.addActionListener(new ActionListener()
2095     {
2096       @Override
2097       public void actionPerformed(ActionEvent e)
2098       {
2099         applyToAllGroups_actionPerformed(applyToAllGroups.isSelected());
2100       }
2101     });
2102
2103     textColour = new JMenuItem(
2104             MessageManager.getString("label.text_colour"));
2105     textColour.addActionListener(new ActionListener()
2106     {
2107       @Override
2108       public void actionPerformed(ActionEvent e)
2109       {
2110         textColour_actionPerformed();
2111       }
2112     });
2113
2114     conservationMenuItem = new JCheckBoxMenuItem(
2115             MessageManager.getString("action.by_conservation"));
2116     conservationMenuItem.addActionListener(new ActionListener()
2117     {
2118       @Override
2119       public void actionPerformed(ActionEvent e)
2120       {
2121         conservationMenuItem_actionPerformed(
2122                 conservationMenuItem.isSelected());
2123       }
2124     });
2125
2126     abovePIDThreshold = new JCheckBoxMenuItem(
2127             MessageManager.getString("label.above_identity_threshold"));
2128     abovePIDThreshold.addActionListener(new ActionListener()
2129     {
2130       @Override
2131       public void actionPerformed(ActionEvent e)
2132       {
2133         abovePIDThreshold_actionPerformed(abovePIDThreshold.isSelected());
2134       }
2135     });
2136     modifyPID = new JMenuItem(
2137             MessageManager.getString("label.modify_identity_threshold"));
2138     modifyPID.addActionListener(new ActionListener()
2139     {
2140       @Override
2141       public void actionPerformed(ActionEvent e)
2142       {
2143         modifyPID_actionPerformed();
2144       }
2145     });
2146     modifyConservation = new JMenuItem(MessageManager
2147             .getString("label.modify_conservation_threshold"));
2148     modifyConservation.addActionListener(new ActionListener()
2149     {
2150       @Override
2151       public void actionPerformed(ActionEvent e)
2152       {
2153         modifyConservation_actionPerformed();
2154       }
2155     });
2156
2157     annotationColour = new JMenuItem(
2158             MessageManager.getString("action.by_annotation"));
2159     annotationColour.addActionListener(new ActionListener()
2160     {
2161       @Override
2162       public void actionPerformed(ActionEvent e)
2163       {
2164         annotationColour_actionPerformed();
2165       }
2166     });
2167   }
2168
2169   protected void selectHighlightedColumns_actionPerformed(
2170           ActionEvent actionEvent)
2171   {
2172     // TODO Auto-generated method stub
2173
2174   }
2175
2176   /**
2177    * Generate the reverse sequence (or reverse complement if the flag is true)
2178    * and add it to the alignment
2179    * 
2180    * @param complement
2181    */
2182   protected void showReverse_actionPerformed(boolean complement)
2183   {
2184   }
2185
2186   /**
2187    * Try to run script in a Groovy console, having first ensured that this
2188    * alignframe is set as currentAlignFrame in Desktop
2189    */
2190   protected void runGroovy_actionPerformed()
2191   {
2192
2193   }
2194
2195   /**
2196    * Adds the given action listener and key accelerator to the given menu item.
2197    * Also saves in a lookup table to support lookup of action by key stroke.
2198    * 
2199    * @param keyStroke
2200    * @param menuItem
2201    * @param actionListener
2202    */
2203   protected void addMenuActionAndAccelerator(KeyStroke keyStroke,
2204           JMenuItem menuItem, ActionListener actionListener)
2205   {
2206     menuItem.setAccelerator(keyStroke);
2207     accelerators.put(keyStroke, menuItem);
2208     menuItem.addActionListener(actionListener);
2209   }
2210
2211   /**
2212    * Action on clicking sort annotations by type.
2213    * 
2214    * @param sortOrder
2215    */
2216   protected void sortAnnotations_actionPerformed()
2217   {
2218   }
2219
2220   /**
2221    * Action on clicking Show all annotations.
2222    * 
2223    * @param forSequences
2224    *          update sequence-related annotations
2225    * @param forAlignment
2226    *          update non-sequence-related annotations
2227    */
2228   protected void showAllAnnotations_actionPerformed(boolean forSequences,
2229           boolean forAlignment)
2230   {
2231     setAnnotationsVisibility(true, forSequences, forAlignment);
2232   }
2233
2234   /**
2235    * Action on clicking Hide all annotations.
2236    * 
2237    * @param forSequences
2238    *          update sequence-related annotations
2239    * @param forAlignment
2240    *          update non-sequence-related annotations
2241    */
2242   protected void hideAllAnnotations_actionPerformed(boolean forSequences,
2243           boolean forAlignment)
2244   {
2245     setAnnotationsVisibility(false, forSequences, forAlignment);
2246   }
2247
2248   /**
2249    * Set the visibility of annotations to true or false. Can act on
2250    * sequence-related annotations, or alignment-related, or both.
2251    * 
2252    * @param visible
2253    * @param forSequences
2254    *          update sequence-related annotations
2255    * @param forAlignment
2256    *          update non-sequence-related annotations
2257    */
2258   protected void setAnnotationsVisibility(boolean visible,
2259           boolean forSequences, boolean forAlignment)
2260   {
2261
2262   }
2263
2264   protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
2265   {
2266     // TODO Auto-generated method stub
2267
2268   }
2269
2270   protected void listenToViewSelections_actionPerformed(ActionEvent e)
2271   {
2272     // TODO Auto-generated method stub
2273
2274   }
2275
2276   protected void showAllhidden_actionPerformed(ActionEvent e)
2277   {
2278     // TODO Auto-generated method stub
2279
2280   }
2281
2282   protected void hideAllButSelection_actionPerformed(ActionEvent e)
2283   {
2284     // TODO Auto-generated method stub
2285
2286   }
2287
2288   protected void hideAllSelection_actionPerformed(ActionEvent e)
2289   {
2290     // TODO Auto-generated method stub
2291
2292   }
2293
2294   protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
2295   {
2296     // TODO Auto-generated method stub
2297
2298   }
2299
2300   protected void showConsensusHistogram_actionPerformed(ActionEvent e)
2301   {
2302     // TODO Auto-generated method stub
2303
2304   }
2305
2306   protected void showSequenceLogo_actionPerformed(ActionEvent e)
2307   {
2308     // TODO Auto-generated method stub
2309
2310   }
2311
2312   protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
2313   {
2314     // TODO Auto-generated method stub
2315
2316   }
2317
2318   protected void showGroupConsensus_actionPerformed(ActionEvent e)
2319   {
2320     // TODO Auto-generated method stub
2321
2322   }
2323
2324   protected void showGroupConservation_actionPerformed(ActionEvent e)
2325   {
2326     // TODO Auto-generated method stub
2327
2328   }
2329
2330   protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
2331   {
2332     // TODO Auto-generated method stub
2333
2334   }
2335
2336   protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
2337   {
2338     // TODO Auto-generated method stub
2339
2340   }
2341
2342   protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
2343   {
2344     // TODO Auto-generated method stub
2345
2346   }
2347
2348   protected void followHighlight_actionPerformed()
2349   {
2350     // TODO Auto-generated method stub
2351
2352   }
2353
2354   protected void showNpFeats_actionPerformed(ActionEvent e)
2355   {
2356     // TODO Auto-generated method stub
2357
2358   }
2359
2360   protected void showDbRefs_actionPerformed(ActionEvent e)
2361   {
2362     // TODO Auto-generated method stub
2363
2364   }
2365
2366   protected void centreColumnLabels_actionPerformed(ActionEvent e)
2367   {
2368   }
2369
2370   protected void buildSortByAnnotationScoresMenu()
2371   {
2372   }
2373
2374   protected void extractScores_actionPerformed(ActionEvent e)
2375   {
2376   }
2377
2378   protected void outputText_actionPerformed(ActionEvent e)
2379   {
2380   }
2381
2382   public void addFromFile_actionPerformed(ActionEvent e)
2383   {
2384
2385   }
2386
2387   public void addFromText_actionPerformed(ActionEvent e)
2388   {
2389
2390   }
2391
2392   public void addFromURL_actionPerformed(ActionEvent e)
2393   {
2394
2395   }
2396
2397   public void exportFeatures_actionPerformed(ActionEvent e)
2398   {
2399
2400   }
2401
2402   public void exportAnnotations_actionPerformed(ActionEvent e)
2403   {
2404
2405   }
2406
2407   protected void htmlMenuItem_actionPerformed(ActionEvent e)
2408   {
2409   }
2410
2411   protected void bioJSMenuItem_actionPerformed(ActionEvent e)
2412   {
2413
2414   }
2415
2416   protected void closeMenuItem_actionPerformed(boolean b)
2417   {
2418   }
2419
2420   protected void redoMenuItem_actionPerformed(ActionEvent e)
2421   {
2422   }
2423
2424   protected void undoMenuItem_actionPerformed(ActionEvent e)
2425   {
2426   }
2427
2428   protected void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2429   {
2430   }
2431
2432   protected void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
2433   {
2434   }
2435
2436   protected void invertSequenceMenuItem_actionPerformed(ActionEvent e)
2437   {
2438   }
2439
2440   protected void remove2LeftMenuItem_actionPerformed(ActionEvent e)
2441   {
2442   }
2443
2444   protected void remove2RightMenuItem_actionPerformed(ActionEvent e)
2445   {
2446   }
2447
2448   protected void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
2449   {
2450   }
2451
2452   protected void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
2453   {
2454   }
2455
2456   protected void wrapMenuItem_actionPerformed(ActionEvent e)
2457   {
2458   }
2459
2460   protected void viewBoxesMenuItem_actionPerformed(ActionEvent e)
2461   {
2462   }
2463
2464   protected void viewTextMenuItem_actionPerformed(ActionEvent e)
2465   {
2466   }
2467
2468   protected void colourTextMenuItem_actionPerformed(ActionEvent e)
2469   {
2470   }
2471
2472   protected void annotationPanelMenuItem_actionPerformed(ActionEvent e)
2473   {
2474   }
2475
2476   protected void overviewMenuItem_actionPerformed(ActionEvent e)
2477   {
2478   }
2479
2480   protected void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
2481   {
2482   }
2483
2484   protected void sortIDMenuItem_actionPerformed(ActionEvent e)
2485   {
2486   }
2487
2488   protected void sortLengthMenuItem_actionPerformed(ActionEvent e)
2489   {
2490   }
2491
2492   protected void sortGroupMenuItem_actionPerformed(ActionEvent e)
2493   {
2494   }
2495
2496   protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
2497   {
2498   }
2499
2500   protected void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
2501   {
2502   }
2503
2504   protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
2505   {
2506   }
2507
2508   protected void conservationMenuItem_actionPerformed(boolean selected)
2509   {
2510   }
2511
2512   protected void printMenuItem_actionPerformed(ActionEvent e)
2513   {
2514   }
2515
2516   protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
2517   {
2518   }
2519
2520   protected void findMenuItem_actionPerformed(ActionEvent e)
2521   {
2522   }
2523
2524   protected void abovePIDThreshold_actionPerformed(boolean selected)
2525   {
2526   }
2527
2528   public void showSeqFeatures_actionPerformed(ActionEvent actionEvent)
2529   {
2530   }
2531
2532   protected void deleteGroups_actionPerformed(ActionEvent e)
2533   {
2534   }
2535
2536   protected void createGroup_actionPerformed(ActionEvent e)
2537   {
2538   }
2539
2540   protected void unGroup_actionPerformed(ActionEvent e)
2541   {
2542   }
2543
2544   protected void copy_actionPerformed(ActionEvent e)
2545   {
2546   }
2547
2548   protected void cut_actionPerformed(ActionEvent e)
2549   {
2550   }
2551
2552   protected void delete_actionPerformed(ActionEvent e)
2553   {
2554   }
2555
2556   protected void pasteNew_actionPerformed(ActionEvent e)
2557           throws IOException, InterruptedException
2558   {
2559   }
2560
2561   protected void pasteThis_actionPerformed(ActionEvent e)
2562           throws IOException, InterruptedException
2563   {
2564   }
2565
2566   protected void applyToAllGroups_actionPerformed(boolean selected)
2567   {
2568   }
2569
2570   protected void hmmBuildRun_actionPerformed(ActionEvent e)
2571           throws IOException, InterruptedException
2572   {
2573   }
2574
2575   protected void hmmSearchRun_actionPerformed(ActionEvent e)
2576   {
2577   }
2578
2579   protected void addDatabase_actionPerformed(ActionEvent e)
2580           throws FileFormatException, IOException
2581   {
2582   }
2583
2584   protected void hmmAlignRun_actionPerformed(ActionEvent e)
2585           throws IOException, InterruptedException
2586   {
2587   }
2588
2589   protected void hmmBuildSettings_actionPerformed(ActionEvent e)
2590           throws IOException, InterruptedException
2591   {
2592   }
2593
2594   protected void hmmSearchSettings_actionPerformed(ActionEvent e)
2595   {
2596   }
2597
2598   protected void hmmAlignSettings_actionPerformed(ActionEvent e)
2599           throws IOException, InterruptedException
2600   {
2601   }
2602
2603   public void createPNG(java.io.File f)
2604   {
2605   }
2606
2607   protected void font_actionPerformed(ActionEvent e)
2608   {
2609   }
2610
2611   protected void seqLimit_actionPerformed(ActionEvent e)
2612   {
2613   }
2614
2615   public void seqDBRef_actionPerformed(ActionEvent e)
2616   {
2617
2618   }
2619
2620   public void createEPS(java.io.File f)
2621   {
2622   }
2623
2624   public void createSVG(java.io.File f)
2625   {
2626
2627   }
2628
2629   protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
2630   {
2631
2632   }
2633
2634   /**
2635    * Template method to handle the 'load T-Coffee scores' menu event.
2636    * <p>
2637    * Subclasses override this method to provide a custom action.
2638    * 
2639    * @param event
2640    *          The raised event
2641    */
2642   protected void loadScores_actionPerformed(ActionEvent event)
2643   {
2644
2645   }
2646
2647   protected void jpred_actionPerformed(ActionEvent e)
2648   {
2649   }
2650
2651   protected void scaleAbove_actionPerformed(ActionEvent e)
2652   {
2653   }
2654
2655   protected void scaleLeft_actionPerformed(ActionEvent e)
2656   {
2657   }
2658
2659   protected void scaleRight_actionPerformed(ActionEvent e)
2660   {
2661   }
2662
2663   protected void modifyPID_actionPerformed()
2664   {
2665   }
2666
2667   protected void modifyConservation_actionPerformed()
2668   {
2669   }
2670
2671   protected void saveAs_actionPerformed(ActionEvent e)
2672   {
2673   }
2674
2675   protected void padGapsMenuitem_actionPerformed(ActionEvent e)
2676   {
2677   }
2678
2679   public void vamsasStore_actionPerformed(ActionEvent e)
2680   {
2681
2682   }
2683
2684   public void vamsasLoad_actionPerformed(ActionEvent e)
2685   {
2686
2687   }
2688
2689   public void showTranslation_actionPerformed(ActionEvent e)
2690   {
2691
2692   }
2693
2694   public void featureSettings_actionPerformed(ActionEvent e)
2695   {
2696
2697   }
2698
2699   public void fetchSequence_actionPerformed(ActionEvent e)
2700   {
2701
2702   }
2703
2704   public void smoothFont_actionPerformed(ActionEvent e)
2705   {
2706
2707   }
2708
2709   public void annotationColour_actionPerformed()
2710   {
2711   }
2712
2713   public void annotationColumn_actionPerformed(ActionEvent e)
2714   {
2715   }
2716
2717   public void associatedData_actionPerformed(ActionEvent e)
2718           throws IOException, InterruptedException
2719   {
2720
2721   }
2722
2723   public void autoCalculate_actionPerformed(ActionEvent e)
2724   {
2725
2726   }
2727
2728   public void sortByTreeOption_actionPerformed(ActionEvent e)
2729   {
2730
2731   }
2732
2733   public void showAllSeqs_actionPerformed(ActionEvent e)
2734   {
2735
2736   }
2737
2738   public void showAllColumns_actionPerformed(ActionEvent e)
2739   {
2740
2741   }
2742
2743   public void hideSelSequences_actionPerformed(ActionEvent e)
2744   {
2745
2746   }
2747
2748   public void hideSelColumns_actionPerformed(ActionEvent e)
2749   {
2750
2751   }
2752
2753   public void hiddenMarkers_actionPerformed(ActionEvent e)
2754   {
2755
2756   }
2757
2758   public void findPdbId_actionPerformed(ActionEvent e)
2759   {
2760
2761   }
2762
2763   public void enterPdbId_actionPerformed(ActionEvent e)
2764   {
2765
2766   }
2767
2768   public void pdbFile_actionPerformed(ActionEvent e)
2769   {
2770
2771   }
2772
2773   public void invertColSel_actionPerformed(ActionEvent e)
2774   {
2775
2776   }
2777
2778   public void tabSelectionChanged(int sel)
2779   {
2780
2781   }
2782
2783   public void tabbedPane_mousePressed(MouseEvent e)
2784   {
2785
2786   }
2787
2788   public void tabbedPane_focusGained(FocusEvent e)
2789   {
2790     requestFocus();
2791   }
2792
2793   public void save_actionPerformed(ActionEvent e)
2794   {
2795
2796   }
2797
2798   public void reload_actionPerformed(ActionEvent e)
2799   {
2800
2801   }
2802
2803   public void newView_actionPerformed(ActionEvent e)
2804   {
2805
2806   }
2807
2808   public void textColour_actionPerformed()
2809   {
2810
2811   }
2812
2813   public void idRightAlign_actionPerformed(ActionEvent e)
2814   {
2815
2816   }
2817
2818   public void expandViews_actionPerformed(ActionEvent e)
2819   {
2820
2821   }
2822
2823   public void gatherViews_actionPerformed(ActionEvent e)
2824   {
2825
2826   }
2827
2828   public void buildTreeSortMenu()
2829   {
2830
2831   }
2832
2833   public void pageSetup_actionPerformed(ActionEvent e)
2834   {
2835
2836   }
2837
2838   public void alignmentProperties()
2839   {
2840
2841   }
2842
2843   protected void expand_newalign(ActionEvent e)
2844   {
2845     // TODO Auto-generated method stub
2846
2847   }
2848
2849   protected boolean isShowAutoCalculatedAbove()
2850   {
2851     return showAutoCalculatedAbove;
2852   }
2853
2854   protected void setShowAutoCalculatedAbove(boolean showAutoCalculatedAbove)
2855   {
2856     this.showAutoCalculatedAbove = showAutoCalculatedAbove;
2857   }
2858
2859   protected SequenceAnnotationOrder getAnnotationSortOrder()
2860   {
2861     return annotationSortOrder;
2862   }
2863
2864   protected void setAnnotationSortOrder(
2865           SequenceAnnotationOrder annotationSortOrder)
2866   {
2867     this.annotationSortOrder = annotationSortOrder;
2868   }
2869
2870   public Map<KeyStroke, JMenuItem> getAccelerators()
2871   {
2872     return this.accelerators;
2873   }
2874
2875   /**
2876    * Returns the selected index of the tabbed pane, or -1 if none selected
2877    * (including the case where the tabbed pane has not been made visible).
2878    * 
2879    * @return
2880    */
2881   public int getTabIndex()
2882   {
2883     return tabbedPane.getSelectedIndex();
2884   }
2885
2886   public JPanel getStatusPanel()
2887   {
2888     return statusPanel;
2889   }
2890
2891   /**
2892    * Sets a reference to the containing split frame. Also makes the 'toggle
2893    * split view' menu item visible and checked.
2894    * 
2895    * @param sf
2896    */
2897   public void setSplitFrame(SplitContainerI sf)
2898   {
2899     this.splitFrame = sf;
2900     if (sf != null)
2901     {
2902       this.showComplementMenuItem.setVisible(true);
2903       this.showComplementMenuItem.setState(true);
2904     }
2905   }
2906
2907   public SplitContainerI getSplitViewContainer()
2908   {
2909     return this.splitFrame;
2910   }
2911
2912   protected void showComplement_actionPerformed(boolean complement)
2913   {
2914   }
2915
2916   protected void showInformationHistogram_actionPerformed(ActionEvent e)
2917   {
2918     // TODO Auto-generated method stub
2919
2920   }
2921
2922   protected void showHMMSequenceLogo_actionPerformed(ActionEvent e)
2923   {
2924
2925   }
2926
2927   protected void normaliseHMMSequenceLogo_actionPerformed(ActionEvent e)
2928   {
2929
2930   }
2931 }