jalviewjsJ2sAltSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_alt_settings}")
jalviewjsJ2sProps = null
jalviewjsJ2sPlugin = jalviewjs_j2s_plugin
+ jalviewjsStderrLaunchFilename = "${jalviewjsSiteDir}/"+(file(jalviewjs_stderr_launch).getName())
eclipseWorkspace = null
eclipseBinary = string("")
eclipseVersion = string("")
eclipseDebug = false
+
// ENDEXT
}
dependsOn jalviewjsBuildSite
}
+
+task jalviewjsCopyStderrLaunchFile(type: Copy) {
+ from file(jalviewjs_stderr_launch)
+ into jalviewjsSiteDir
+
+ inputs.file jalviewjs_stderr_launch
+ outputs.file jalviewjsStderrLaunchFilename
+}
+
+task jalviewjsChromiumProfile {
+ def profileDir = "${jalviewjsBuildDir}/${jalviewjs_chromium_user_dir}/${jalviewjs_chromium_profile_name}"
+ def firstRun = file("${profileDir}/First Run")
+
+ doFirst {
+ mkdir profileDir
+ firstRun.text = ""
+ }
+
+ outputs.file firstRun
+}
+
+task jalviewjsLaunchTest(type: Exec) {
+ group "Test"
+ description "Check JalviewJS opens in a browser"
+ dependsOn jalviewjsBuildSite
+ dependsOn jalviewjsCopyStderrLaunchFile
+ dependsOn jalviewjsChromiumProfile
+
+ def chromiumBinary = jalviewjs_chromium_binary
+ if (chromiumBinary.startsWith("~/")) {
+ chromiumBinary = System.getProperty("user.home") + chromiumBinary.substring(1)
+ }
+
+ doFirst {
+ def exec = file(chromiumBinary)
+ if (!exec.exists()) {
+ throw new GradleException("Could not find chromium binary '${chromiumBinary}'. Cannot run task ${name}.")
+ }
+ }
+
+ executable(chromiumBinary)
+ args([
+ "--headless=new",
+ "--timeout=15000",
+ "--virtual-time-budget=15000",
+ "--user-data-dir=${jalviewjsBuildDir}/${jalviewjs_chromium_user_dir}",
+ "--profile-directory=${jalviewjs_chromium_profile_name}",
+ "--allow-file-access-from-files",
+ "--enable-logging=stderr",
+ jalviewjsStderrLaunchFilename
+ ])
+
+ standardOutput = new ByteArrayOutputStream()
+ errorOutput = new ByteArrayOutputStream()
+
+ doLast {
+ def found = false
+ def stderr = errorOutput.toString()
+ stderr.eachLine { line ->
+ if (line.contains(jalviewjs_desktop_init_string)) {
+ println("Found line '"+line+"'")
+ found = true
+ return
+ }
+ }
+ if (!found) {
+ throw new GradleException("Could not find evidence of Desktop launch in JalviewJS.")
+ }
+ }
+}
jalviewjs_closure_compiler = tools/closure_compiler.jar
jalviewjs_j2s_closure_stdout = j2s-closure.out
+# for checking jalviewjs launches okay
+jalviewjs_chromium_binary = ~/buildtools/chromium/chrome
+jalviewjs_chromium_user_dir = chromium
+jalviewjs_chromium_profile_name = BUILD
+jalviewjs_stderr_launch = utils/jalviewjs/chromium_test/jalview_bin_Jalview-stderr.html
+jalviewjs_desktop_init_string = JALVIEWJS: CREATED DESKTOP
testp=gradle.properties
}
});
desktop.addMouseListener(ma);
+
+ if (Platform.isJS())
+ {
+ // used for jalviewjsTest
+ jalview.bin.Console.info("JALVIEWJS: CREATED DESKTOP");
+ }
}
/**
String title = "View of desktop";
ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
title);
- try {
+ try
+ {
exporter.doExport(of, this, width, height, title);
- } catch (ImageOutputException ioex) {
- jalview.bin.Console.error("Unexpected error whilst writing Jalview desktop snapshot as EPS",ioex);
+ } catch (ImageOutputException ioex)
+ {
+ jalview.bin.Console.error(
+ "Unexpected error whilst writing Jalview desktop snapshot as EPS",
+ ioex);
}
}
*/
public static void closeDesktop()
{
- if (Desktop.instance != null) {
+ if (Desktop.instance != null)
+ {
Desktop.instance.closeAll_actionPerformed(null);
Desktop.instance.setVisible(false);
Desktop.instance.dispose();
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<title>SwingJS test Jalview</title><meta charset="utf-8" />
+<script src="swingjs/swingjs2.js"></script>
+<script>
+if (!self.SwingJS)alert('swingjs2.js was not found. It needs to be in swingjs folder in the same directory as ' + document.location.href)
+Info = {
+ code: null,
+ main: "jalview.bin.Jalview",
+ core: "NONE",
+ width: 850,
+ height: 550,
+ readyFunction: null,
+ serverURL: 'https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
+ j2sPath: 'swingjs/j2s',
+ console: window.console,
+ allowjavascript: true
+}
+</script>
+</head>
+<body>
+<script>
+// we define console.err because swingjs2.js calls it instead of console.error
+window.console.err = function() {
+ this.error.apply(this,arguments);
+}
+SwingJS.getApplet('testApplet', Info)
+getClassList = function(){J2S._saveFile('_j2sclasslist.txt', Clazz.ClassFilesLoaded.sort().join('\n'))}
+</script>
+<div style="position:absolute;left:900px;top:30px;width:600px;height:300px;">
+<div id="sysoutdiv" contentEditable="true" style="border:1px solid green;width:100%;height:95%;overflow:auto"></div>
+This is System.out. <a href="javascript:testApplet._clearConsole()">clear it</a> <br>Add ?j2snocore to URL to see full class list; ?j2sdebug to use uncompressed j2s/core files <br><a href="javascript:getClassList()">get _j2sClassList.txt</a>
+</div>
+</body>
+</html>