From: hansonr Date: Sat, 23 Jun 2018 16:57:20 +0000 (+0100) Subject: JAL-3026 JDesktop/JInternalFrames support + relative URL file loading X-Git-Tag: Release_2_11_4_0~45^2~18^2~662 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e6fd516209d8b5162cd155c9d500ca27a6dd8e1e;p=jalview.git JAL-3026 JDesktop/JInternalFrames support + relative URL file loading - preliminary - no minimization to JDesktopIcon - no maximization - z-order not checked See JalviewJS2.java new SwingJS-site.zip AlignFrame.java: JS bypass for addServiceListeners() AppletFormatAdapter.java: DataSourceType.java: FileParse.java: adds DataSourceType.RELATIVE_URL for indicating files relative to the HTML page. Desktop.java: JS bypass for Console, Dialog Thread, News, Vamsas, and URL links Jalview.java JS bypass forparsing h, help, nodisplay, nogui, jabaws, startup example. --- diff --git a/SwingJS-site.zip b/SwingJS-site.zip index 035a3e0..7b51835 100644 Binary files a/SwingJS-site.zip and b/SwingJS-site.zip differ diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 2007814..0d7143d 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -214,17 +214,6 @@ public class Jalview ArgsParser aparser = new ArgsParser(args); boolean headless = false; - if (aparser.contains("help") || aparser.contains("h")) - { - showUsage(); - System.exit(0); - } - if (aparser.contains("nodisplay") || aparser.contains("nogui") - || aparser.contains("headless")) - { - System.setProperty("java.awt.headless", "true"); - headless = true; - } String usrPropsFile = aparser.getValue("props"); Cache.loadProperties(usrPropsFile); // must do this before if (usrPropsFile != null) @@ -233,23 +222,41 @@ public class Jalview "CMD [-props " + usrPropsFile + "] executed successfully!"); } - // anything else! - - final String jabawsUrl = aparser.getValue("jabaws"); - if (jabawsUrl != null) + /** + * BH 2018 ignoring this section for JS + * + * @j2sNative + */ { - try + if (aparser.contains("help") || aparser.contains("h")) { - Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl); - System.out.println( - "CMD [-jabaws " + jabawsUrl + "] executed successfully!"); - } catch (MalformedURLException e) + showUsage(); + System.exit(0); + } + if (aparser.contains("nodisplay") || aparser.contains("nogui") + || aparser.contains("headless")) { - System.err.println( - "Invalid jabaws parameter: " + jabawsUrl + " ignored"); + System.setProperty("java.awt.headless", "true"); + headless = true; + } + // anything else! + + final String jabawsUrl = aparser.getValue("jabaws"); + if (jabawsUrl != null) + { + try + { + Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl); + System.out.println( + "CMD [-jabaws " + jabawsUrl + "] executed successfully!"); + } catch (MalformedURLException e) + { + System.err.println( + "Invalid jabaws parameter: " + jabawsUrl + " ignored"); + } } - } + } String defs = aparser.getValue("setprop"); while (defs != null) { @@ -346,55 +353,65 @@ public class Jalview desktop = new Desktop(); desktop.setInBatchMode(true); // indicate we are starting up desktop.setVisible(true); - desktop.startServiceDiscovery(); - if (!aparser.contains("nousagestats")) - { - startUsageStats(desktop); - } - else - { - System.err.println("CMD [-nousagestats] executed successfully!"); - } - if (!aparser.contains("noquestionnaire")) + /** + * BH 2018 JS bypass this section + * + * @j2sNative + * + */ { - String url = aparser.getValue("questionnaire"); - if (url != null) + desktop.startServiceDiscovery(); + if (!aparser.contains("nousagestats")) { - // Start the desktop questionnaire prompter with the specified - // questionnaire - Cache.log.debug("Starting questionnaire url at " + url); - desktop.checkForQuestionnaire(url); - System.out.println( - "CMD questionnaire[-" + url + "] executed successfully!"); + startUsageStats(desktop); } else { - if (Cache.getProperty("NOQUESTIONNAIRES") == null) + System.err.println("CMD [-nousagestats] executed successfully!"); + } + + if (!aparser.contains("noquestionnaire")) + { + String url = aparser.getValue("questionnaire"); + if (url != null) { // Start the desktop questionnaire prompter with the specified // questionnaire - // String defurl = - // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl"; - // // - String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl"; - Cache.log.debug( - "Starting questionnaire with default url: " + defurl); - desktop.checkForQuestionnaire(defurl); + Cache.log.debug("Starting questionnaire url at " + url); + desktop.checkForQuestionnaire(url); + System.out.println("CMD questionnaire[-" + url + + "] executed successfully!"); + } + else + { + if (Cache.getProperty("NOQUESTIONNAIRES") == null) + { + // Start the desktop questionnaire prompter with the specified + // questionnaire + // String defurl = + // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl"; + // // + String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl"; + Cache.log.debug( + "Starting questionnaire with default url: " + defurl); + desktop.checkForQuestionnaire(defurl); + } } } - } - else - { - System.err.println("CMD [-noquestionnaire] executed successfully!"); - } + else + { + System.err + .println("CMD [-noquestionnaire] executed successfully!"); + } - if (!aparser.contains("nonews")) - { - desktop.checkForNews(); - } + if (!aparser.contains("nonews")) + { + desktop.checkForNews(); + } - BioJsHTMLOutput.updateBioJS(); + BioJsHTMLOutput.updateBioJS(); + } } String file = null, data = null; @@ -514,7 +531,7 @@ public class Jalview } System.out.println("CMD [-open " + file + "] executed successfully!"); - if (!file.startsWith("http://")) + if (!isJS && !file.startsWith("http://")) { if (!(new File(file)).exists()) { @@ -526,7 +543,7 @@ public class Jalview } } - protocol = AppletFormatAdapter.checkProtocol(file); + protocol = AppletFormatAdapter.checkProtocol(file); try { @@ -757,7 +774,8 @@ public class Jalview // And the user // //////////////////// - if (!headless && file == null && vamsasImport == null + if (/** @j2sNative false && */ // BH 2018 + !headless && file == null && vamsasImport == null && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true)) { file = jalview.bin.Cache.getDefault("STARTUP_FILE", diff --git a/src/jalview/bin/JalviewJS2.java b/src/jalview/bin/JalviewJS2.java new file mode 100644 index 0000000..55d9a1f --- /dev/null +++ b/src/jalview/bin/JalviewJS2.java @@ -0,0 +1,41 @@ +package jalview.bin; + +/** + * Entry point for JalviewJS development. + * + * + * + * @author RM + * + */ +public class JalviewJS2 +{ + + static { + /** + * @j2sNative + * + * thisApplet.__Info.args = + * ["open","http://www.jalview.org/builds/release/examples/uniref50.fa","features", + * "http://www.jalview.org/builds/release/examples/exampleFeatures.txt"]; + */ + + } + + public static void main(String[] args) throws Exception + { + String[] defaultArgs = new String[] { "noquestionnaire" }; + String[] anew = new String[args.length + defaultArgs.length]; + for (int i = 0; i < args.length; i++) + { + anew[i] = args[i]; + } + for (int i = 0; i < defaultArgs.length; i++) + { + anew[i + args.length] = defaultArgs[i]; + } + Jalview.main(args); + } + + +} diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 9de9e3b..a2b1e47 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -378,7 +378,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (Desktop.desktop != null) { this.setDropTarget(new java.awt.dnd.DropTarget(this, this)); + /** + * BH 2018 ignore service listeners + * + * @j2sNative + * + */ + { addServiceListeners(); + } setGUINucleotide(); } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 569257f..fc95f83 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -382,65 +382,39 @@ public class Desktop extends jalview.jbgui.GDesktop setBounds((screenSize.width - 900) / 2, (screenSize.height - 650) / 2, 900, 650); } - jconsole = new Console(this, showjconsole); - // add essential build information - jconsole.setHeader( - "Jalview Version: " + jalview.bin.Cache.getProperty("VERSION") - + "\n" + "Jalview Installation: " - + jalview.bin.Cache.getDefault("INSTALLATION", - "unknown") - + "\n" + "Build Date: " - + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") - + "\n" + "Java version: " - + System.getProperty("java.version") + "\n" - + System.getProperty("os.arch") + " " - + System.getProperty("os.name") + " " - + System.getProperty("os.version")); + /** + * BH 2018 + * + * @j2sNative + */ + { - showConsole(showjconsole); + jconsole = new Console(this, showjconsole); + // add essential build information + jconsole.setHeader("Jalview Version: " + + jalview.bin.Cache.getProperty("VERSION") + "\n" + + "Jalview Installation: " + + jalview.bin.Cache.getDefault("INSTALLATION", "unknown") + + "\n" + "Build Date: " + + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n" + + "Java version: " + System.getProperty("java.version") + "\n" + + System.getProperty("os.arch") + " " + + System.getProperty("os.name") + " " + + System.getProperty("os.version")); - showNews.setVisible(false); + showConsole(showjconsole); - experimentalFeatures.setSelected(showExperimental()); + showNews.setVisible(false); - getIdentifiersOrgData(); + experimentalFeatures.setSelected(showExperimental()); - checkURLLinks(); + getIdentifiersOrgData(); - this.addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent evt) - { - quit(); - } - }); - - MouseAdapter ma; - this.addMouseListener(ma = new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent evt) - { - if (evt.isPopupTrigger()) // Mac - { - showPasteMenu(evt.getX(), evt.getY()); - } - } - - @Override - public void mouseReleased(MouseEvent evt) - { - if (evt.isPopupTrigger()) // Windows - { - showPasteMenu(evt.getX(), evt.getY()); - } - } - }); - desktop.addMouseListener(ma); + checkURLLinks(); this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); // Spawn a thread that shows the splashscreen + SwingUtilities.invokeLater(new Runnable() { @Override @@ -478,6 +452,41 @@ public class Desktop extends jalview.jbgui.GDesktop } }); + + } // end BH 2018 ignore + + this.addWindowListener(new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent evt) + { + quit(); + } + }); + + MouseAdapter ma; + this.addMouseListener(ma = new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent evt) + { + if (evt.isPopupTrigger()) // Mac + { + showPasteMenu(evt.getX(), evt.getY()); + } + } + + @Override + public void mouseReleased(MouseEvent evt) + { + if (evt.isPopupTrigger()) // Windows + { + showPasteMenu(evt.getX(), evt.getY()); + } + } + }); + desktop.addMouseListener(ma); + } /** @@ -517,20 +526,28 @@ public class Desktop extends jalview.jbgui.GDesktop public void checkForNews() { + + /** + * BH 2018 + * + * @j2sNative + */ + { final Desktop me = this; // Thread off the news reader, in case there are connection problems. addDialogThread(new Runnable() { - @Override - public void run() - { - Cache.log.debug("Starting news thread."); + @Override + public void run() + { + Cache.log.debug("Starting news thread."); - jvnews = new BlogReader(me); - showNews.setVisible(true); - Cache.log.debug("Completed news thread."); - } + jvnews = new BlogReader(me); + showNews.setVisible(true); + Cache.log.debug("Completed news thread."); + } }); + } } public void getIdentifiersOrgData() @@ -564,6 +581,12 @@ public class Desktop extends jalview.jbgui.GDesktop void showNews(boolean visible) { + /** + * BH 2018 + * + * @j2sNative + * + */ { Cache.log.debug((visible ? "Showing" : "Hiding") + " news."); showNews.setSelected(visible); @@ -647,7 +670,8 @@ public class Desktop extends jalview.jbgui.GDesktop private void doVamsasClientCheck() { - if (jalview.bin.Cache.vamsasJarsPresent()) + if (/** @j2sNative false && */ // BH 2018 + jalview.bin.Cache.vamsasJarsPresent()) { setupVamsasDisconnectedGui(); VamsasMenu.setVisible(true); @@ -1501,11 +1525,14 @@ public class Desktop extends jalview.jbgui.GDesktop */ void showConsole(boolean selected) { - showConsole.setSelected(selected); // TODO: decide if we should update properties file - Cache.setProperty("SHOW_JAVA_CONSOLE", - Boolean.valueOf(selected).toString()); - jconsole.setVisible(selected); + if (jconsole != null) // BH 2018 + { + showConsole.setSelected(selected); + Cache.setProperty("SHOW_JAVA_CONSOLE", + Boolean.valueOf(selected).toString()); + jconsole.setVisible(selected); + } } void reorderAssociatedWindows(boolean minimize, boolean close) @@ -2365,7 +2392,8 @@ public class Desktop extends jalview.jbgui.GDesktop @Override public void run() { - if (Cache.getDefault("CHECKURLLINKS", true)) + if (/** @j2sNative false && */ // BH 2018 + Cache.getDefault("CHECKURLLINKS", true)) { // check what the actual links are - if it's just the default don't // bother with the warning diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 5e209e6..3f51ea8 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -422,6 +422,10 @@ public class AppletFormatAdapter { protocol = DataSourceType.URL; } + else if (jalview.bin.Jalview.isJS) + { + protocol = DataSourceType.RELATIVE_URL; + } else if (new File(data).exists()) { protocol = DataSourceType.FILE; diff --git a/src/jalview/io/DataSourceType.java b/src/jalview/io/DataSourceType.java index 55e585c..7e2aeab 100644 --- a/src/jalview/io/DataSourceType.java +++ b/src/jalview/io/DataSourceType.java @@ -22,5 +22,5 @@ package jalview.io; public enum DataSourceType { - FILE, URL, PASTE, CLASSLOADER, LOCALURL; + FILE, URL, PASTE, CLASSLOADER, RELATIVE_URL; } diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index 1ee1db6..bf0a844 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -341,7 +341,7 @@ public class FileParse } } } - else if (sourceType == DataSourceType.LOCALURL) + else if (sourceType == DataSourceType.RELATIVE_URL) { String data = null; /**