From: gmungoc Date: Mon, 23 Jul 2018 13:42:08 +0000 (+0100) Subject: JAL-3056 suppress menu options, and repoint Help, for JalviewJS X-Git-Tag: Release_2_11_4_0~45^2~18^2~503^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c9a98f3738fa773afd01ea5d5881b604855fa1b8;p=jalview.git JAL-3056 suppress menu options, and repoint Help, for JalviewJS --- diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index e890cb8..3e6e545 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -89,13 +89,21 @@ public class Jalview public static AlignFrame currentAlignFrame; - public static boolean isJS = /** @j2sNative true || */ // BH 2018 - false; + /** + * Answers true if Jalview is running as Javascript, else false. The value is + * set at compile time. + * + * @return + */ + public static boolean isJS() + { + return /** @j2sNative true || */ + false; + } static { - - if (!isJS) + if (!isJS()) { // BH 2018 // grab all the rights we can the JVM Policy.setPolicy(new Policy() @@ -199,7 +207,7 @@ public class Jalview void doMain(String[] args) { - if (!isJS) + if (!isJS()) { System.setSecurityManager(null); } @@ -530,7 +538,7 @@ public class Jalview } System.out.println("CMD [-open " + file + "] executed successfully!"); - if (!isJS && !file.startsWith("http://")) + if (!isJS() && !file.startsWith("http://")) { if (!(new File(file)).exists()) { diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 81aacda..564f04a 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -41,6 +41,7 @@ import jalview.jbgui.GSplitFrame; import jalview.jbgui.GStructureViewer; import jalview.structure.StructureSelectionManager; import jalview.urls.IdOrgSettings; +import jalview.util.BrowserLauncher; import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; import jalview.util.Platform; @@ -1377,19 +1378,24 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! + * Action on requesting Help documentation */ @Override - public void documentationMenuItem_actionPerformed(ActionEvent e) + public void documentationMenuItem_actionPerformed() { try { - Help.showHelpWindow(); + if (Jalview.isJS()) + { + BrowserLauncher.openURL("http://www.jalview.org/help.html"); + } + else + { + Help.showHelpWindow(); + } } catch (Exception ex) { + System.err.println("Error opening help: " + ex.getMessage()); } } @@ -1593,16 +1599,12 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! + * Prompts the user to choose a file and then saves the Jalview state as a + * Jalview project file */ @Override - public void saveState_actionPerformed(ActionEvent e) + public void saveState_actionPerformed() { - // TODO: JAL-3048 not needed for Jalview-JS - JalviewFileChooser chooser = new JalviewFileChooser("jvp", "Jalview Project"); @@ -1668,16 +1670,11 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! + * Prompts the user to choose a file and loads in as a Jalview project file */ @Override - public void loadState_actionPerformed(ActionEvent e) + public void loadState_actionPerformed() { - // TODO: JAL-3048 not needed for Jalview-JS - JalviewFileChooser chooser = new JalviewFileChooser( Cache.getProperty("LAST_DIRECTORY"), new String[] { "jvp", "jar" }, diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index b0fee88..95cbb61 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -444,7 +444,7 @@ public class AppletFormatAdapter { protocol = DataSourceType.URL; } - else if (jalview.bin.Jalview.isJS) + else if (jalview.bin.Jalview.isJS()) { protocol = DataSourceType.RELATIVE_URL; } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index a83c688..1910930 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -23,6 +23,7 @@ package jalview.jbgui; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.api.SplitContainerI; import jalview.bin.Cache; +import jalview.bin.Jalview; import jalview.gui.JvSwingUtils; import jalview.gui.Preferences; import jalview.io.FileFormats; @@ -1716,7 +1717,10 @@ public class GAlignFrame extends JInternalFrame alignFrameMenuBar.add(formatMenu); alignFrameMenuBar.add(colourMenu); alignFrameMenuBar.add(calculateMenu); - alignFrameMenuBar.add(webService); + if (!Jalview.isJS()) + { + alignFrameMenuBar.add(webService); + } fileMenu.add(fetchSequence); fileMenu.add(addSequenceMenu); @@ -1734,10 +1738,7 @@ public class GAlignFrame extends JInternalFrame fileMenu.add(exportAnnotations); fileMenu.add(loadTreeMenuItem); fileMenu.add(associatedData); - /* - * No VCF import in Jalview-JS - * @j2sNative - */ + if (!Jalview.isJS()) { fileMenu.add(loadVcf); } @@ -1774,8 +1775,11 @@ public class GAlignFrame extends JInternalFrame hideMenu.add(hideAllSelection); hideMenu.add(hideAllButSelection); viewMenu.add(newView); - viewMenu.add(expandViews); - viewMenu.add(gatherViews); + if (!Jalview.isJS()) + { + viewMenu.add(expandViews); + viewMenu.add(gatherViews); + } viewMenu.addSeparator(); viewMenu.add(showMenu); viewMenu.add(hideMenu); @@ -1835,17 +1839,26 @@ public class GAlignFrame extends JInternalFrame calculateMenu.addSeparator(); calculateMenu.add(expandAlignment); calculateMenu.add(extractScores); - calculateMenu.addSeparator(); - calculateMenu.add(runGroovy); + if (!Jalview.isJS()) + { + calculateMenu.addSeparator(); + calculateMenu.add(runGroovy); + } webServiceNoServices = new JMenuItem( MessageManager.getString("label.no_services")); webService.add(webServiceNoServices); - exportImageMenu.add(htmlMenuItem); + if (!Jalview.isJS()) + { + exportImageMenu.add(htmlMenuItem); + } exportImageMenu.add(epsFile); exportImageMenu.add(createPNG); exportImageMenu.add(createBioJS); - exportImageMenu.add(createSVG); + if (!Jalview.isJS()) + { + exportImageMenu.add(createSVG); + } addSequenceMenu.add(addFromFile); addSequenceMenu.add(addFromText); addSequenceMenu.add(addFromURL); diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 11a558c..9ffd701 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -21,6 +21,7 @@ package jalview.jbgui; import jalview.api.AlignmentViewPanel; +import jalview.bin.Jalview; import jalview.io.FileFormatException; import jalview.util.MessageManager; import jalview.util.Platform; @@ -225,7 +226,7 @@ public class GDesktop extends JFrame @Override public void actionPerformed(ActionEvent e) { - documentationMenuItem_actionPerformed(e); + documentationMenuItem_actionPerformed(); } }); this.getContentPane().setLayout(flowLayout1); @@ -246,7 +247,7 @@ public class GDesktop extends JFrame @Override public void actionPerformed(ActionEvent e) { - saveState_actionPerformed(e); + saveState_actionPerformed(); } }); loadState.setText(MessageManager.getString("action.load_project")); @@ -255,7 +256,7 @@ public class GDesktop extends JFrame @Override public void actionPerformed(ActionEvent e) { - loadState_actionPerformed(e); + loadState_actionPerformed(); } }); inputMenu.setText(MessageManager.getString("label.input_alignment")); @@ -423,9 +424,12 @@ public class GDesktop extends JFrame desktopMenubar.add(windowMenu); FileMenu.add(inputMenu); FileMenu.add(inputSequence); - FileMenu.addSeparator(); - FileMenu.add(saveState); - FileMenu.add(loadState); + if (!Jalview.isJS()) + { + FileMenu.addSeparator(); + FileMenu.add(saveState); + FileMenu.add(loadState); + } FileMenu.addSeparator(); FileMenu.add(quit); HelpMenu.add(aboutMenuItem); @@ -437,11 +441,17 @@ public class GDesktop extends JFrame VamsasMenu.add(vamsasSave); VamsasMenu.add(vamsasStop); toolsMenu.add(preferences); - toolsMenu.add(showMemusage); - toolsMenu.add(showConsole); + if (!Jalview.isJS()) + { + toolsMenu.add(showMemusage); + toolsMenu.add(showConsole); + } toolsMenu.add(showNews); - toolsMenu.add(garbageCollect); - toolsMenu.add(groovyShell); + if (!Jalview.isJS()) + { + toolsMenu.add(garbageCollect); + toolsMenu.add(groovyShell); + } toolsMenu.add(experimentalFeatures); // toolsMenu.add(snapShotWindow); inputMenu.add(inputLocalFileMenuItem); @@ -551,13 +561,7 @@ public class GDesktop extends JFrame { } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void documentationMenuItem_actionPerformed(ActionEvent e) + protected void documentationMenuItem_actionPerformed() { } @@ -581,33 +585,11 @@ public class GDesktop extends JFrame { } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - public void saveState_actionPerformed(ActionEvent e) - { - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - public void loadState_actionPerformed(ActionEvent e) + public void saveState_actionPerformed() { } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - public void loadJalviewAlign_actionPerformed(ActionEvent e) + public void loadState_actionPerformed() { } diff --git a/src/jalview/jbgui/GUserDefinedColours.java b/src/jalview/jbgui/GUserDefinedColours.java index 3d7d779..1b2b069 100755 --- a/src/jalview/jbgui/GUserDefinedColours.java +++ b/src/jalview/jbgui/GUserDefinedColours.java @@ -20,6 +20,7 @@ */ package jalview.jbgui; +import jalview.bin.Jalview; import jalview.gui.JvSwingUtils; import jalview.util.MessageManager; @@ -230,7 +231,10 @@ public class GUserDefinedColours extends JPanel okCancelPanel.add(applyButton); okCancelPanel.add(okButton); okCancelPanel.add(cancelButton); - lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH); + if (!Jalview.isJS()) + { + lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH); + } lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH); namePanel.add(schemeName, java.awt.BorderLayout.CENTER);