X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGAlignFrame.java;h=8bbfb8d10d23cbf2511c6600d831ef7fc4e9ea3a;hb=8fa69554edf6aeb278b4a4afd8e2b60264fdccd8;hp=3a6e603ac95d7516e04aa454c311e97a5f81ffa8;hpb=cbe8877688ba73d591239cf9a654eb2582f771b8;p=jalview.git diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 3a6e603..8bbfb8d 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -21,12 +21,14 @@ package jalview.jbgui; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.analysis.GeneticCodeI; +import jalview.analysis.GeneticCodes; import jalview.api.SplitContainerI; import jalview.bin.Cache; -import jalview.bin.Jalview; import jalview.gui.JvSwingUtils; import jalview.gui.Preferences; import jalview.io.FileFormats; +import jalview.schemes.ResidueColourScheme; import jalview.util.MessageManager; import jalview.util.Platform; @@ -60,15 +62,18 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; +@SuppressWarnings("serial") public class GAlignFrame extends JInternalFrame { protected JMenuBar alignFrameMenuBar = new JMenuBar(); protected JMenuItem closeMenuItem = new JMenuItem(); - protected JMenu webService = new JMenu(); + public JMenu webService = new JMenu();// BH 2019 was protected, but not + // sufficient for AlignFrame thread run - protected JMenuItem webServiceNoServices; + public JMenuItem webServiceNoServices;// BH 2019 was protected, but not + // sufficient for AlignFrame thread run protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); @@ -76,7 +81,9 @@ public class GAlignFrame extends JInternalFrame protected JMenu sortByAnnotScore = new JMenu(); - public JLabel statusBar = new JLabel(); + public JLabel statusBar = new JLabel(); // BH 2019 was protected, but not + // sufficient for + // AlignFrame.printWriter protected JMenu outputTextboxMenu = new JMenu(); @@ -124,7 +131,7 @@ public class GAlignFrame extends JInternalFrame protected JMenuItem modifyPID; - protected JMenuItem annotationColour; + protected JRadioButtonMenuItem annotationColour; protected JMenu sortByTreeMenu = new JMenu(); @@ -138,7 +145,7 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem(); - protected JMenuItem showTranslation = new JMenuItem(); + protected JMenu showTranslation = new JMenu(); protected JMenuItem showReverse = new JMenuItem(); @@ -170,7 +177,7 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem(); - protected JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane(); + protected JTabbedPane tabbedPane = new JTabbedPane(); protected JMenuItem reload = new JMenuItem(); @@ -197,14 +204,14 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem normaliseSequenceLogo = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem(); - + protected JMenuItem openFeatureSettings; private SequenceAnnotationOrder annotationSortOrder; private boolean showAutoCalculatedAbove = false; - private Map accelerators = new HashMap(); + private Map accelerators = new HashMap<>(); private SplitContainerI splitFrame; @@ -212,6 +219,10 @@ public class GAlignFrame extends JInternalFrame { try { + + // for Web-page embedding using id=align-frame-div + setName("jalview-alignment"); + jbInit(); setJMenuBar(alignFrameMenuBar); @@ -236,7 +247,7 @@ public class GAlignFrame extends JInternalFrame System.err.println(e.toString()); } - if (!Platform.isAMac()) + if (Platform.allowMnemonics()) // was "not mac and not JS" { closeMenuItem.setMnemonic('C'); outputTextboxMenu.setMnemonic('T'); @@ -285,16 +296,7 @@ public class GAlignFrame extends JInternalFrame addMenuActionAndAccelerator(keyStroke, closeMenuItem, al); JMenu editMenu = new JMenu(MessageManager.getString("action.edit")); - JMenu viewMenu = new JMenu(MessageManager.getString("action.view")) { - - public void setPopupMenuVisible(boolean b) { - if (b) { - openFeatureSettings.setEnabled(haveAlignmentFeatures()); - } - super.setPopupMenuVisible(b); - } - - }; + JMenu viewMenu = new JMenu(MessageManager.getString("action.view")); JMenu annotationsMenu = new JMenu( MessageManager.getString("action.annotations")); JMenu showMenu = new JMenu(MessageManager.getString("action.show")); @@ -979,7 +981,7 @@ public class GAlignFrame extends JInternalFrame @Override public void actionPerformed(ActionEvent e) { - copy_actionPerformed(e); + copy_actionPerformed(); } }; addMenuActionAndAccelerator(keyStroke, copy, al); @@ -992,7 +994,7 @@ public class GAlignFrame extends JInternalFrame @Override public void actionPerformed(ActionEvent e) { - cut_actionPerformed(e); + cut_actionPerformed(); } }; addMenuActionAndAccelerator(keyStroke, cut, al); @@ -1004,7 +1006,7 @@ public class GAlignFrame extends JInternalFrame @Override public void actionPerformed(ActionEvent e) { - delete_actionPerformed(e); + delete_actionPerformed(); } }); @@ -1233,16 +1235,33 @@ public class GAlignFrame extends JInternalFrame vamsasStore_actionPerformed(e); } }); + + /* + * Translate as cDNA with sub-menu of translation tables + */ showTranslation .setText(MessageManager.getString("label.translate_cDNA")); - showTranslation.addActionListener(new ActionListener() + boolean first = true; + for (final GeneticCodeI table : GeneticCodes.getInstance() + .getCodeTables()) { - @Override - public void actionPerformed(ActionEvent e) + JMenuItem item = new JMenuItem(table.getId() + " " + table.getName()); + showTranslation.add(item); + item.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showTranslation_actionPerformed(table); + } + }); + if (first) { - showTranslation_actionPerformed(e); + showTranslation.addSeparator(); } - }); + first = false; + } + showReverse.setText(MessageManager.getString("label.reverse")); showReverse.addActionListener(new ActionListener() { @@ -1293,7 +1312,6 @@ public class GAlignFrame extends JInternalFrame openFeatureSettings = new JMenuItem( MessageManager.getString("action.feature_settings")); - openFeatureSettings.setEnabled(false); openFeatureSettings.addActionListener(new ActionListener() { @Override @@ -1302,6 +1320,10 @@ public class GAlignFrame extends JInternalFrame featureSettings_actionPerformed(e); } }); + + /* + * add sub-menu of database we can fetch from + */ JMenuItem fetchSequence = new JMenuItem( MessageManager.getString("label.fetch_sequences")); fetchSequence.addActionListener(new ActionListener() @@ -1309,7 +1331,7 @@ public class GAlignFrame extends JInternalFrame @Override public void actionPerformed(ActionEvent e) { - fetchSequence_actionPerformed(e); + fetchSequence_actionPerformed(); } }); @@ -1323,7 +1345,8 @@ public class GAlignFrame extends JInternalFrame associatedData_actionPerformed(e); } }); - loadVcf = new JMenuItem(MessageManager.getString("label.load_vcf_file")); + loadVcf = new JMenuItem( + MessageManager.getString("label.load_vcf_file")); loadVcf.setToolTipText(MessageManager.getString("label.load_vcf")); loadVcf.addActionListener(new ActionListener() { @@ -1717,7 +1740,7 @@ public class GAlignFrame extends JInternalFrame alignFrameMenuBar.add(formatMenu); alignFrameMenuBar.add(colourMenu); alignFrameMenuBar.add(calculateMenu); - if (!Jalview.isJS()) + if (!Platform.isJS()) { alignFrameMenuBar.add(webService); } @@ -1738,7 +1761,7 @@ public class GAlignFrame extends JInternalFrame fileMenu.add(exportAnnotations); fileMenu.add(loadTreeMenuItem); fileMenu.add(associatedData); - if (!Jalview.isJS()) + if (!Platform.isJS()) { fileMenu.add(loadVcf); } @@ -1775,11 +1798,8 @@ public class GAlignFrame extends JInternalFrame hideMenu.add(hideAllSelection); hideMenu.add(hideAllButSelection); viewMenu.add(newView); - if (!Jalview.isJS()) - { - viewMenu.add(expandViews); - viewMenu.add(gatherViews); - } + viewMenu.add(expandViews); + viewMenu.add(gatherViews); viewMenu.addSeparator(); viewMenu.add(showMenu); viewMenu.add(hideMenu); @@ -1839,7 +1859,7 @@ public class GAlignFrame extends JInternalFrame calculateMenu.addSeparator(); calculateMenu.add(expandAlignment); calculateMenu.add(extractScores); - if (!Jalview.isJS()) + if (!Platform.isJS()) { calculateMenu.addSeparator(); calculateMenu.add(runGroovy); @@ -1848,15 +1868,15 @@ public class GAlignFrame extends JInternalFrame webServiceNoServices = new JMenuItem( MessageManager.getString("label.no_services")); webService.add(webServiceNoServices); - if (!Jalview.isJS()) + if (!Platform.isJS()) { exportImageMenu.add(htmlMenuItem); } exportImageMenu.add(epsFile); exportImageMenu.add(createPNG); - exportImageMenu.add(createBioJS); - if (!Jalview.isJS()) + if (!Platform.isJS()) { + exportImageMenu.add(createBioJS); exportImageMenu.add(createSVG); } addSequenceMenu.add(addFromFile); @@ -1899,12 +1919,6 @@ public class GAlignFrame extends JInternalFrame // selectMenu.add(listenToViewSelections); } - protected boolean haveAlignmentFeatures() - { - // because gAlignFrame is not an abstract class -- see AlignFrame - return false; - } - protected void loadVcf_actionPerformed() { } @@ -1980,8 +1994,9 @@ public class GAlignFrame extends JInternalFrame } }); - annotationColour = new JMenuItem( + annotationColour = new JRadioButtonMenuItem( MessageManager.getString("action.by_annotation")); + annotationColour.setName(ResidueColourScheme.ANNOTATION_COLOUR); annotationColour.addActionListener(new ActionListener() { @Override @@ -2367,15 +2382,15 @@ public class GAlignFrame extends JInternalFrame { } - protected void copy_actionPerformed(ActionEvent e) + protected void copy_actionPerformed() { } - protected void cut_actionPerformed(ActionEvent e) + protected void cut_actionPerformed() { } - protected void delete_actionPerformed(ActionEvent e) + protected void delete_actionPerformed() { } @@ -2477,7 +2492,7 @@ public class GAlignFrame extends JInternalFrame } - public void showTranslation_actionPerformed(ActionEvent e) + public void showTranslation_actionPerformed(GeneticCodeI codeTable) { } @@ -2487,7 +2502,7 @@ public class GAlignFrame extends JInternalFrame } - public void fetchSequence_actionPerformed(ActionEvent e) + public void fetchSequence_actionPerformed() { }