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