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