From: James Procter Date: Mon, 23 Oct 2023 11:02:42 +0000 (+0100) Subject: Merge branch 'feature/JAL-4307_hetatm_showhide' into develop X-Git-Tag: Release_2_11_4_0~126 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3b74463d9ba726384240d7707b6ea416a24c6b59;hp=fa25baa61ac89d1bba5eccf6fe3df85928191706;p=jalview.git Merge branch 'feature/JAL-4307_hetatm_showhide' into develop --- diff --git a/build.gradle b/build.gradle index 8ac2757..e5abc77 100644 --- a/build.gradle +++ b/build.gradle @@ -52,7 +52,7 @@ plugins { id 'application' id 'eclipse' id "com.diffplug.gradle.spotless" version "3.28.0" - id 'com.github.johnrengelman.shadow' version '4.0.3' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'com.install4j.gradle' version '10.0.3' id 'com.dorongold.task-tree' version '2.1.1' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree id 'com.palantir.git-version' version '0.13.0' apply false @@ -1851,7 +1851,9 @@ tasks.withType(Test).matching {t -> t.getName().startsWith("testTask")}.all { te showExceptions true showCauses true showStackTraces true - + if (test_output) { + showStandardStreams true + } info.events = [ TestLogEvent.FAILED ] } @@ -2154,12 +2156,33 @@ shadowJar { if (buildDist) { dependsOn makeDist } - from ("${jalviewDir}/${libDistDir}") { - include("*.jar") - } - manifest { - attributes "Implementation-Version": JALVIEW_VERSION, - "Application-Name": applicationName + + def jarFiles = fileTree(dir: "${jalviewDir}/${libDistDir}", include: "*.jar", exclude: "regex.jar").getFiles() + def groovyJars = jarFiles.findAll {it1 -> file(it1).getName().startsWith("groovy-swing")} + def otherJars = jarFiles.findAll {it2 -> !file(it2).getName().startsWith("groovy-swing")} + from groovyJars + from otherJars + + // we need to include the groovy-swing Include-Package for it to run in the shadowJar + doFirst { + def jarFileManifests = [] + groovyJars.each { jarFile -> + def mf = zipTree(jarFile).getFiles().find { it.getName().equals("MANIFEST.MF") } + if (mf != null) { + jarFileManifests += mf + } + } + + manifest { + attributes "Implementation-Version": JALVIEW_VERSION, "Application-Name": applicationName + from (jarFileManifests) { + eachEntry { details -> + if (!details.key.equals("Import-Package")) { + details.exclude() + } + } + } + } } duplicatesStrategy "INCLUDE" diff --git a/doc/building.md b/doc/building.md index 34d5d67..aee827d 100644 --- a/doc/building.md +++ b/doc/building.md @@ -336,7 +336,7 @@ the `tests/` folder. A summary of results should appear in your console. You can run different defined groups of tests with ```bash -gradle test -PtestngGroups=Network +gradle test -Ptestng_groups=Network ``` Available groups include Functional (default), Network, External. @@ -348,9 +348,15 @@ Some of Jalview's Functional tests don't pass reliably in all environments. We t To exclude one or more groups of tests, add them as a comma separated list in testngExcludedGroups. ```bash -gradle test -PtestngExcludedGroups=Not-bamboo +gradle test -Ptestng_excluded_groups=Not-bamboo ``` +#### Viewing stdout and stderr for tests +By default, gradle doesn't report any of the output or error streams produced by tests. You can enable output by setting the following: + +```bash +gradle test -Ptest_output=1 +``` ### Installer packaging with *install4j* diff --git a/examples/groovy/ComputePeptideVariants.groovy b/examples/groovy/ComputePeptideVariants.groovy index 6caa69c..e5ece51 100644 --- a/examples/groovy/ComputePeptideVariants.groovy +++ b/examples/groovy/ComputePeptideVariants.groovy @@ -1,6 +1,6 @@ import jalview.datamodel.SequenceFeature import jalview.gui.Desktop -def af = jalview.bin.Jalview.currentAlignFrame +def af = Jalview.getCurrentAlignFrame() def av = af.viewport def fr = Desktop.getAlignFrameFor(av.codingComplement).getFeatureRenderer() def counts = 0 @@ -29,4 +29,4 @@ for (seq in av.alignment.sequences) } af.getFeatureRenderer().featuresAdded() af.alignPanel.paintAlignment(true, true) -println "Added " + countm + " missense and " + counts + " synonymous variants" \ No newline at end of file +println "Added " + countm + " missense and " + counts + " synonymous variants" diff --git a/examples/groovy/JvLoadTester.groovy b/examples/groovy/JvLoadTester.groovy index d844d62..cc92e40 100644 --- a/examples/groovy/JvLoadTester.groovy +++ b/examples/groovy/JvLoadTester.groovy @@ -21,7 +21,7 @@ import jalview.gui.*; import jalview.io.*; -def class JvLoadTest { +class JvLoadTest { FileLoader fl = null; def String safename = null; JvLoadTest(String sname) { @@ -155,4 +155,4 @@ def JvLoadTest newJvLoadTest(String tempFile) { System.gc(); jalview.gui.Desktop.instance.desktop.showMemoryUsage(true); return new JvLoadTest(tempFile) -} \ No newline at end of file +} diff --git a/examples/groovy/PIDmatrix.groovy b/examples/groovy/PIDmatrix.groovy index b97abcc..76b9de7 100644 --- a/examples/groovy/PIDmatrix.groovy +++ b/examples/groovy/PIDmatrix.groovy @@ -56,7 +56,7 @@ printSimilarityMatrix(true,true,SimilarityParams.Jalview) void printSimilarityMatrix(boolean selview=false, boolean includeids=true, SimilarityParams pidMethod) { - def currentAlignFrame = jalview.bin.Jalview.getCurrentAlignFrame() + def currentAlignFrame = Jalview.getCurrentAlignFrame() jalview.gui.AlignViewport av = currentAlignFrame.getCurrentView() @@ -96,4 +96,4 @@ void printSimilarityMatrix(boolean selview=false, boolean includeids=true, Simil print "\n" } -} \ No newline at end of file +} diff --git a/examples/groovy/alignLoadedFile.groovy b/examples/groovy/alignLoadedFile.groovy index 764fdae..df68e2b 100644 --- a/examples/groovy/alignLoadedFile.groovy +++ b/examples/groovy/alignLoadedFile.groovy @@ -20,6 +20,7 @@ */ // run an alignment on the current alignFrame import jalview.ws.jws2.*; +import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.datamodel.*; // First get the JABA service discoverer and see if there are any services. @@ -33,7 +34,7 @@ if (!disc.isRunning() && !disc.hasServices()) disc.run(); } -for (jalview.ws.jws2.Jws2Discoverer.Jws2Instance service: disc.getServices()) { +for (jalview.ws.jws2.jabaws2.Jws2Instance service: disc.getServices()) { if (service.serviceType.indexOf("uscle")>-1) { // now - go through the services if any, and find a Muscle service diff --git a/examples/groovy/annotationForSelectedSequence.groovy b/examples/groovy/annotationForSelectedSequence.groovy index abfad35..7cb3082 100644 --- a/examples/groovy/annotationForSelectedSequence.groovy +++ b/examples/groovy/annotationForSelectedSequence.groovy @@ -31,7 +31,7 @@ import java.awt.datatransfer.StringSelection import static java.awt.Toolkit.* -def curviewport = Jalview.getAlignFrames()[Jalview.getAlignFrames().length-1].getViewport(); +def curviewport = Jalview.getCurrentAlignFrame().getViewport(); // TSV output by default. // change "\t" to "," to output CSV file diff --git a/examples/groovy/parseproperties.groovy b/examples/groovy/parseproperties.groovy index 879bd49..ceec6d2 100644 --- a/examples/groovy/parseproperties.groovy +++ b/examples/groovy/parseproperties.groovy @@ -1,19 +1,19 @@ /* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors - * + * * This file is part of Jalview. - * + * * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License + * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. @@ -23,10 +23,9 @@ import jalview.datamodel.*; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; -def af = Jalview.getAlignFrames(); -def al = af[0].viewport.alignment; +def al = Jalview.getCurrentAlignFrame().viewport.alignment; ParseProperties pp = new ParseProperties(al); -pp.getScoresFromDescription("Score", "ScanPS Raw Score", "([-0-9.+]+)"); +pp.getScoresFromDescription("Score", "ScanPS Raw Score", "([-0-9.+]+)", true); def sqs = al.getSequenceAt(0); def annots = sqs.getAnnotation(); diff --git a/examples/groovy/printtitle.groovy b/examples/groovy/printtitle.groovy index b3387ea..a048d65 100644 --- a/examples/groovy/printtitle.groovy +++ b/examples/groovy/printtitle.groovy @@ -1,35 +1,35 @@ /* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors - * + * * This file is part of Jalview. - * + * * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License + * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ // do something groovy in jalview println "Hello World.\n" -println "First sequence is " + currentAlFrame.viewport.alignment.getSequenceAt(0).getDisplayId(true) +println "First sequence is " + Jalview.getCurrentAlignFrame().viewport.alignment.getSequenceAt(0).getDisplayId(true) def alf = Jalview.getAlignFrames() for (ala in alf) { - // ala is an jalview.gui.AlignFrame object + // ala is an jalview.gui.AlignFrame object println ala.getTitle() // get the parent jalview.datamodel.Alignment from the alignment viewport def alignment = ala.viewport.alignment // get the first sequence from the jalview.datamodel.Alignment object - def seq = alignment.getSequenceAt(0) + def seq = alignment.getSequenceAt(0) } Jalview.quit() diff --git a/examples/groovy/removeFeaturesByGroup.groovy b/examples/groovy/removeFeaturesByGroup.groovy index 341e06f..c947a5b 100644 --- a/examples/groovy/removeFeaturesByGroup.groovy +++ b/examples/groovy/removeFeaturesByGroup.groovy @@ -46,6 +46,7 @@ for (ala in af) } } } + ala.repaint(); } diff --git a/examples/groovy/selectColumnsByFeatureAndGroup.groovy b/examples/groovy/selectColumnsByFeatureAndGroup.groovy index b8edaa7..aaa3405 100644 --- a/examples/groovy/selectColumnsByFeatureAndGroup.groovy +++ b/examples/groovy/selectColumnsByFeatureAndGroup.groovy @@ -23,7 +23,7 @@ import jalview.datamodel.*; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; import java.util.BitSet; -import javax.swing.JOptionPane; +import jalview.gui.JvOptionPane; import groovy.swing.SwingBuilder; def toselect = getFeatureInput(); // change this to select the desired feature type @@ -81,7 +81,7 @@ for (ala in Jalview.getAlignFrames()) { cs.addElement(i); } ala.viewport.setColumnSelection(cs); - ala.alignPanel.paintAlignment(true); + ala.alignPanel.paintAlignment(true, true); ala.statusBar.setText("Marked "+bs.cardinality()+" columns containing features of type "+toselect) } else { ala.statusBar.setText("No features of type "+toselect+" found."); @@ -96,4 +96,4 @@ String getFeatureInput(){ null, 'Select columns by feature by type','Enter type of feature', JvOptionPane.OK_OPTION) return response - } \ No newline at end of file + } diff --git a/examples/groovy/sitesForSelectedColumns.groovy b/examples/groovy/sitesForSelectedColumns.groovy index 8165373..f775f18 100644 --- a/examples/groovy/sitesForSelectedColumns.groovy +++ b/examples/groovy/sitesForSelectedColumns.groovy @@ -29,7 +29,7 @@ import java.awt.datatransfer.StringSelection import static java.awt.Toolkit.* -def curviewport = Jalview.getAlignFrames()[Jalview.getAlignFrames().length-1].getViewport() +def curviewport = Jalview.getCurrentAlignFrame().getViewport() def debug = false diff --git a/examples/groovy/stripUniprotPrefixes.groovy b/examples/groovy/stripUniprotPrefixes.groovy index 71b3a9f..5a01da4 100644 --- a/examples/groovy/stripUniprotPrefixes.groovy +++ b/examples/groovy/stripUniprotPrefixes.groovy @@ -29,7 +29,7 @@ def af = Jalview.getAlignFrames(); for (ala in af) { - def al = ala.viewport.alignment; + def al = ala.getViewport().getAlignment(); if (al!=null) { SequenceI[] seqs = al.getSequencesArray(); @@ -47,5 +47,6 @@ for (ala in af) } } } + ala.repaint(); } - \ No newline at end of file + diff --git a/examples/groovy/visibleFeaturesCounter.groovy b/examples/groovy/visibleFeaturesCounter.groovy index b3180f8..510f600 100644 --- a/examples/groovy/visibleFeaturesCounter.groovy +++ b/examples/groovy/visibleFeaturesCounter.groovy @@ -1,38 +1,37 @@ /* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors - * + * * This file is part of Jalview. - * + * * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License + * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -import jalview.bin.Jalview import jalview.workers.FeatureSetCounterI import jalview.workers.AlignmentAnnotationFactory /* * Demonstration of FeatureSetCounterI - * compute annotation tracks counting number of displayed + * compute annotation tracks counting number of displayed * features of each type in each column */ /* * discover features on the current view */ - -def featuresDisp=Jalview.currentAlignFrame.currentView.featuresDisplayed + +def featuresDisp=Jalview.getCurrentAlignFrame().currentView.featuresDisplayed if (featuresDisp == null) { print 'Need at least one feature visible on alignment' } @@ -40,12 +39,12 @@ def visibleFeatures=featuresDisp.visibleFeatures.toList() assert 'java.util.ArrayList' == visibleFeatures.class.name /* - * A closure that returns an array of features present + * A closure that returns an array of features present * for each feature type in visibleFeatures - * Argument 'features' will be a list of SequenceFeature + * Argument 'features' will be a list of SequenceFeature */ -def getCounts = - { features -> +def getCounts = + { features -> int[] obs = new int[visibleFeatures.size] for (sf in features) { @@ -56,9 +55,9 @@ def getCounts = * or sf.getValue(attributeName) for GFF 'column 9' properties */ int pos = 0 - for (type in visibleFeatures) + for (type in visibleFeatures) { - if (type.equals(sf.type)) + if (type.equals(sf.type)) { obs[pos]++ } @@ -67,19 +66,19 @@ def getCounts = } obs } - + /* * Define something that counts each visible feature type */ def columnSetCounter = [ - getNames: { visibleFeatures as String[] }, + getNames: { visibleFeatures as String[] }, getDescriptions: { visibleFeatures as String[] }, getMinColour: { [0, 255, 255] as int[] }, // cyan getMaxColour: { [0, 0, 255] as int[] }, // blue - count: - { res, feats -> - getCounts.call(feats) + count: + { res, feats -> + getCounts.call(feats) } ] as FeatureSetCounterI diff --git a/getdown/lib/FJVL_VERSION b/getdown/lib/FJVL_VERSION index 25d39f4..2d83e61 100644 --- a/getdown/lib/FJVL_VERSION +++ b/getdown/lib/FJVL_VERSION @@ -1 +1 @@ -1.8.3-1.3.0_FJVL +1.8.3-1.3.1_FJVL diff --git a/getdown/lib/JVL_VERSION b/getdown/lib/JVL_VERSION index 12110b2..7d618e2 100644 --- a/getdown/lib/JVL_VERSION +++ b/getdown/lib/JVL_VERSION @@ -1 +1 @@ -1.8.3-1.3.0_JVL +1.8.3-1.3.1_JVL diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index fb8f1bc..3fc97b5 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index c74dcc5..6ba0a6d 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index e1f1726..7c75a34 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/ant/pom.xml b/getdown/src/getdown/ant/pom.xml index d8bb7e9..4c91f74 100644 --- a/getdown/src/getdown/ant/pom.xml +++ b/getdown/src/getdown/ant/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.3.0_FJVL + 1.8.3-1.3.1_FJVL getdown-ant diff --git a/getdown/src/getdown/core/pom.xml b/getdown/src/getdown/core/pom.xml index 6126686..2e43522 100644 --- a/getdown/src/getdown/core/pom.xml +++ b/getdown/src/getdown/core/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.3.0_FJVL + 1.8.3-1.3.1_FJVL getdown-core diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index 9d9fe14..435ebbd 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -1137,7 +1137,6 @@ public class Application String query = jalviewUri.getQuery(); _appargs.clear(); - _appargs.add("-open"); if (host != null && host.length() > 0) { URL newUrl = new URL( (https?"https":"http") @@ -1253,8 +1252,6 @@ public class Application } if (ext != null && LOCATOR_FILE_EXTENSION.equals(ext.toLowerCase(Locale.ROOT))) { // this file extension should have been dealt with in Getdown class - } else { - _appargs.add(0, "-open"); } } diff --git a/getdown/src/getdown/launcher/pom.xml b/getdown/src/getdown/launcher/pom.xml index 4374899..c6b9ff3 100644 --- a/getdown/src/getdown/launcher/pom.xml +++ b/getdown/src/getdown/launcher/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.3.0_FJVL + 1.8.3-1.3.1_FJVL getdown-launcher diff --git a/getdown/src/getdown/mvn_cmd b/getdown/src/getdown/mvn_cmd index ba092a7..10942f8 100755 --- a/getdown/src/getdown/mvn_cmd +++ b/getdown/src/getdown/mvn_cmd @@ -3,7 +3,7 @@ if [ x$JVLVERSION != x ]; then export VERSION=$JVLVERSION else - export VERSION=1.8.3-1.3.0_JVL + export VERSION=1.8.3-1.3.1_JVL fi if [ x${VERSION%_JVL} = x$VERSION ]; then diff --git a/getdown/src/getdown/pom.xml b/getdown/src/getdown/pom.xml index 51e9514..cf32333 100644 --- a/getdown/src/getdown/pom.xml +++ b/getdown/src/getdown/pom.xml @@ -10,7 +10,7 @@ com.threerings.getdown getdown pom - 1.8.3-1.3.0_FJVL + 1.8.3-1.3.1_FJVL getdown An application installer and updater. diff --git a/gradle.properties b/gradle.properties index c2e217f..79fb11d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,6 +28,8 @@ jalview_keydig = SHA1 testng_groups = Functional testng_excluded_groups = +test_output = + j8libDir = j8lib j11libDir = j11lib diff --git a/help/help/html/features/clarguments-reference.html b/help/help/html/features/clarguments-reference.html index b2e29e9..b1588e5 100644 --- a/help/help/html/features/clarguments-reference.html +++ b/help/help/html/features/clarguments-reference.html @@ -92,6 +92,11 @@ + ‑‑javaconsole / ‑‑nojavaconsole + Show (/ or don't show) the Java Console. Using one of these overrides any saved Preference. + + + ‑‑questionnaire / ‑‑noquestionnaire Show (/ or don't show) the questionnaire if one is available. diff --git a/help/help/html/features/groovy.html b/help/help/html/features/groovy.html index cb0b10c..6b5c4c0 100644 --- a/help/help/html/features/groovy.html +++ b/help/help/html/features/groovy.html @@ -20,11 +20,11 @@ * The Jalview Authors are detailed in the 'AUTHORS' file. --> -Groovy Shell +Groovy Console

- The Groovy Shell + The Groovy Console

Groovy (www.groovy-lang.org) @@ -41,8 +41,8 @@ short pause, you should then see the Groovy Console appear. This allows you to interactively execute Groovy - scripts whilst Jalview is running. We've also provided a Calculations→Execute - Groovy Script button so you can execute the currently loaded + scripts whilst Jalview is running. We've also provided a Calculations→Run + Groovy Console Script button so you can execute the currently loaded groovy script whilst viewing an alignment.

@@ -63,31 +63,36 @@ we recommend you also take a look at Jalview's source, since all the public methods of the jalview class hierarchy can be called from Groovy scripts. In addition, the following objects are also defined: +

- -
    -
  • Jalview - this is bound to jalview.bin.Jalview.
    Useful - methods include: +
  • Jalview - this is bound to jalview.bin.groovy.JalviewObject providing access to the following useful + methods:
    • Jalview.getAlignFrames() - returns a list of jalview.gui.AlignFrame objects
    • Jalview.getCurrentAlignFrame() - returns the alignment - window which is currently being looked at by the user
    • + window which has most recently been in focus. If you change focus to another alignment window then re-running Jalview.getCurrentAlignFrame() will return the new AlignFrame.
  • -
  • currentAlFrame - this is only defined when - running a Groovy script via the --groovy command line argument. It - returns the first alignment window created after acting on the - other arguments passed on the command line.
  • +
  • currentAlFrame When used on the command line this refers to the current opened alignment. +
    + When used from the Groovy Console, it refers to the alignment that was in focus when the Groovy Console was opened. +
    + When a Groovy Console script is run from Calculate->Run Groovy Console Script, currentAlFrame us updated to that alignment.

+ If you specify a --groovy argument before an --open argument + then you should ensure your script doesn't refer to currentAlFrame. +

+ +

A simple script

  • Getting the title, alignment and first sequence from the current alignFrame
    -def alf = Jalview.getAlignFrames();
    -print alf[0].getTitle();
    -def alignment = alf[0].viewport.alignment;
    +def al = Jalview.getCurrentAlignFrame();
    +print al.getTitle();
    +def alignment = al.viewport.alignment;
     def seq = alignment.getSequenceAt(0);
     
  • diff --git a/help/help/html/groovy/featuresCounter.html b/help/help/html/groovy/featuresCounter.html index bd7144e..494dd3e 100644 --- a/help/help/html/groovy/featuresCounter.html +++ b/help/help/html/groovy/featuresCounter.html @@ -36,7 +36,7 @@
  • Copy and paste it into the groovy script console
  • Load the example Feredoxin project (the one that opens by default when you first launched Jalview)
  • -
  • Select Calculations→Execute Groovy +
  • Select Calculations→Run Groovy Console Script from the alignment window's menu bar to run the script on the current view.
  • diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index fb8f1bc..3fc97b5 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j11lib/groovy-4.0.15.jar b/j11lib/groovy-4.0.15.jar new file mode 100644 index 0000000..8423d99 Binary files /dev/null and b/j11lib/groovy-4.0.15.jar differ diff --git a/j11lib/groovy-all-2.4.21-indy.jar b/j11lib/groovy-all-2.4.21-indy.jar deleted file mode 100644 index 15ee98d..0000000 Binary files a/j11lib/groovy-all-2.4.21-indy.jar and /dev/null differ diff --git a/j11lib/groovy-ant-4.0.15.jar b/j11lib/groovy-ant-4.0.15.jar new file mode 100644 index 0000000..b6a39ac Binary files /dev/null and b/j11lib/groovy-ant-4.0.15.jar differ diff --git a/j11lib/groovy-astbuilder-4.0.15.jar b/j11lib/groovy-astbuilder-4.0.15.jar new file mode 100644 index 0000000..f341fac Binary files /dev/null and b/j11lib/groovy-astbuilder-4.0.15.jar differ diff --git a/j11lib/groovy-cli-commons-4.0.15.jar b/j11lib/groovy-cli-commons-4.0.15.jar new file mode 100644 index 0000000..b482258 Binary files /dev/null and b/j11lib/groovy-cli-commons-4.0.15.jar differ diff --git a/j11lib/groovy-cli-picocli-4.0.15.jar b/j11lib/groovy-cli-picocli-4.0.15.jar new file mode 100644 index 0000000..3223ba9 Binary files /dev/null and b/j11lib/groovy-cli-picocli-4.0.15.jar differ diff --git a/j11lib/groovy-console-4.0.15.jar b/j11lib/groovy-console-4.0.15.jar new file mode 100644 index 0000000..04a402a Binary files /dev/null and b/j11lib/groovy-console-4.0.15.jar differ diff --git a/j11lib/groovy-contracts-4.0.15.jar b/j11lib/groovy-contracts-4.0.15.jar new file mode 100644 index 0000000..6825657 Binary files /dev/null and b/j11lib/groovy-contracts-4.0.15.jar differ diff --git a/j11lib/groovy-datetime-4.0.15.jar b/j11lib/groovy-datetime-4.0.15.jar new file mode 100644 index 0000000..312575a Binary files /dev/null and b/j11lib/groovy-datetime-4.0.15.jar differ diff --git a/j11lib/groovy-dateutil-4.0.15.jar b/j11lib/groovy-dateutil-4.0.15.jar new file mode 100644 index 0000000..5893f97 Binary files /dev/null and b/j11lib/groovy-dateutil-4.0.15.jar differ diff --git a/j11lib/groovy-docgenerator-4.0.15.jar b/j11lib/groovy-docgenerator-4.0.15.jar new file mode 100644 index 0000000..bf76564 Binary files /dev/null and b/j11lib/groovy-docgenerator-4.0.15.jar differ diff --git a/j11lib/groovy-ginq-4.0.15.jar b/j11lib/groovy-ginq-4.0.15.jar new file mode 100644 index 0000000..46f561e Binary files /dev/null and b/j11lib/groovy-ginq-4.0.15.jar differ diff --git a/j11lib/groovy-groovydoc-4.0.15.jar b/j11lib/groovy-groovydoc-4.0.15.jar new file mode 100644 index 0000000..b818919 Binary files /dev/null and b/j11lib/groovy-groovydoc-4.0.15.jar differ diff --git a/j11lib/groovy-groovysh-4.0.15.jar b/j11lib/groovy-groovysh-4.0.15.jar new file mode 100644 index 0000000..253eff6 Binary files /dev/null and b/j11lib/groovy-groovysh-4.0.15.jar differ diff --git a/j11lib/groovy-jmx-4.0.15.jar b/j11lib/groovy-jmx-4.0.15.jar new file mode 100644 index 0000000..8667ac4 Binary files /dev/null and b/j11lib/groovy-jmx-4.0.15.jar differ diff --git a/j11lib/groovy-json-4.0.15.jar b/j11lib/groovy-json-4.0.15.jar new file mode 100644 index 0000000..76b486a Binary files /dev/null and b/j11lib/groovy-json-4.0.15.jar differ diff --git a/j11lib/groovy-jsr223-4.0.15.jar b/j11lib/groovy-jsr223-4.0.15.jar new file mode 100644 index 0000000..5ae9f69 Binary files /dev/null and b/j11lib/groovy-jsr223-4.0.15.jar differ diff --git a/j11lib/groovy-macro-4.0.15.jar b/j11lib/groovy-macro-4.0.15.jar new file mode 100644 index 0000000..e5f7abb Binary files /dev/null and b/j11lib/groovy-macro-4.0.15.jar differ diff --git a/j11lib/groovy-macro-library-4.0.15.jar b/j11lib/groovy-macro-library-4.0.15.jar new file mode 100644 index 0000000..92c208f Binary files /dev/null and b/j11lib/groovy-macro-library-4.0.15.jar differ diff --git a/j11lib/groovy-nio-4.0.15.jar b/j11lib/groovy-nio-4.0.15.jar new file mode 100644 index 0000000..e6e2ad8 Binary files /dev/null and b/j11lib/groovy-nio-4.0.15.jar differ diff --git a/j11lib/groovy-servlet-4.0.15.jar b/j11lib/groovy-servlet-4.0.15.jar new file mode 100644 index 0000000..711a1e2 Binary files /dev/null and b/j11lib/groovy-servlet-4.0.15.jar differ diff --git a/j11lib/groovy-sql-4.0.15.jar b/j11lib/groovy-sql-4.0.15.jar new file mode 100644 index 0000000..058db44 Binary files /dev/null and b/j11lib/groovy-sql-4.0.15.jar differ diff --git a/j11lib/groovy-swing-4.0.15.jar b/j11lib/groovy-swing-4.0.15.jar new file mode 100644 index 0000000..848d074 Binary files /dev/null and b/j11lib/groovy-swing-4.0.15.jar differ diff --git a/j11lib/groovy-templates-4.0.15.jar b/j11lib/groovy-templates-4.0.15.jar new file mode 100644 index 0000000..3cd0245 Binary files /dev/null and b/j11lib/groovy-templates-4.0.15.jar differ diff --git a/j11lib/groovy-test-4.0.15.jar b/j11lib/groovy-test-4.0.15.jar new file mode 100644 index 0000000..e600dc7 Binary files /dev/null and b/j11lib/groovy-test-4.0.15.jar differ diff --git a/j11lib/groovy-test-junit5-4.0.15.jar b/j11lib/groovy-test-junit5-4.0.15.jar new file mode 100644 index 0000000..abcc69a Binary files /dev/null and b/j11lib/groovy-test-junit5-4.0.15.jar differ diff --git a/j11lib/groovy-testng-4.0.15.jar b/j11lib/groovy-testng-4.0.15.jar new file mode 100644 index 0000000..60c1b58 Binary files /dev/null and b/j11lib/groovy-testng-4.0.15.jar differ diff --git a/j11lib/groovy-toml-4.0.15.jar b/j11lib/groovy-toml-4.0.15.jar new file mode 100644 index 0000000..ad49634 Binary files /dev/null and b/j11lib/groovy-toml-4.0.15.jar differ diff --git a/j11lib/groovy-typecheckers-4.0.15.jar b/j11lib/groovy-typecheckers-4.0.15.jar new file mode 100644 index 0000000..dc113c3 Binary files /dev/null and b/j11lib/groovy-typecheckers-4.0.15.jar differ diff --git a/j11lib/groovy-xml-4.0.15.jar b/j11lib/groovy-xml-4.0.15.jar new file mode 100644 index 0000000..21aeea0 Binary files /dev/null and b/j11lib/groovy-xml-4.0.15.jar differ diff --git a/j11lib/groovy-yaml-4.0.15.jar b/j11lib/groovy-yaml-4.0.15.jar new file mode 100644 index 0000000..207d47d Binary files /dev/null and b/j11lib/groovy-yaml-4.0.15.jar differ diff --git a/j11lib/javaparser-core-3.25.5.jar b/j11lib/javaparser-core-3.25.5.jar new file mode 100644 index 0000000..92eed53 Binary files /dev/null and b/j11lib/javaparser-core-3.25.5.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index fb8f1bc..3fc97b5 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ diff --git a/j8lib/groovy-4.0.15.jar b/j8lib/groovy-4.0.15.jar new file mode 100644 index 0000000..8423d99 Binary files /dev/null and b/j8lib/groovy-4.0.15.jar differ diff --git a/j8lib/groovy-all-2.4.21-indy.jar b/j8lib/groovy-all-2.4.21-indy.jar deleted file mode 100644 index 15ee98d..0000000 Binary files a/j8lib/groovy-all-2.4.21-indy.jar and /dev/null differ diff --git a/j8lib/groovy-ant-4.0.15.jar b/j8lib/groovy-ant-4.0.15.jar new file mode 100644 index 0000000..b6a39ac Binary files /dev/null and b/j8lib/groovy-ant-4.0.15.jar differ diff --git a/j8lib/groovy-astbuilder-4.0.15.jar b/j8lib/groovy-astbuilder-4.0.15.jar new file mode 100644 index 0000000..f341fac Binary files /dev/null and b/j8lib/groovy-astbuilder-4.0.15.jar differ diff --git a/j8lib/groovy-cli-commons-4.0.15.jar b/j8lib/groovy-cli-commons-4.0.15.jar new file mode 100644 index 0000000..b482258 Binary files /dev/null and b/j8lib/groovy-cli-commons-4.0.15.jar differ diff --git a/j8lib/groovy-cli-picocli-4.0.15.jar b/j8lib/groovy-cli-picocli-4.0.15.jar new file mode 100644 index 0000000..3223ba9 Binary files /dev/null and b/j8lib/groovy-cli-picocli-4.0.15.jar differ diff --git a/j8lib/groovy-console-4.0.15.jar b/j8lib/groovy-console-4.0.15.jar new file mode 100644 index 0000000..04a402a Binary files /dev/null and b/j8lib/groovy-console-4.0.15.jar differ diff --git a/j8lib/groovy-contracts-4.0.15.jar b/j8lib/groovy-contracts-4.0.15.jar new file mode 100644 index 0000000..6825657 Binary files /dev/null and b/j8lib/groovy-contracts-4.0.15.jar differ diff --git a/j8lib/groovy-datetime-4.0.15.jar b/j8lib/groovy-datetime-4.0.15.jar new file mode 100644 index 0000000..312575a Binary files /dev/null and b/j8lib/groovy-datetime-4.0.15.jar differ diff --git a/j8lib/groovy-dateutil-4.0.15.jar b/j8lib/groovy-dateutil-4.0.15.jar new file mode 100644 index 0000000..5893f97 Binary files /dev/null and b/j8lib/groovy-dateutil-4.0.15.jar differ diff --git a/j8lib/groovy-docgenerator-4.0.15.jar b/j8lib/groovy-docgenerator-4.0.15.jar new file mode 100644 index 0000000..bf76564 Binary files /dev/null and b/j8lib/groovy-docgenerator-4.0.15.jar differ diff --git a/j8lib/groovy-ginq-4.0.15.jar b/j8lib/groovy-ginq-4.0.15.jar new file mode 100644 index 0000000..46f561e Binary files /dev/null and b/j8lib/groovy-ginq-4.0.15.jar differ diff --git a/j8lib/groovy-groovydoc-4.0.15.jar b/j8lib/groovy-groovydoc-4.0.15.jar new file mode 100644 index 0000000..b818919 Binary files /dev/null and b/j8lib/groovy-groovydoc-4.0.15.jar differ diff --git a/j8lib/groovy-groovysh-4.0.15.jar b/j8lib/groovy-groovysh-4.0.15.jar new file mode 100644 index 0000000..253eff6 Binary files /dev/null and b/j8lib/groovy-groovysh-4.0.15.jar differ diff --git a/j8lib/groovy-jmx-4.0.15.jar b/j8lib/groovy-jmx-4.0.15.jar new file mode 100644 index 0000000..8667ac4 Binary files /dev/null and b/j8lib/groovy-jmx-4.0.15.jar differ diff --git a/j8lib/groovy-json-4.0.15.jar b/j8lib/groovy-json-4.0.15.jar new file mode 100644 index 0000000..76b486a Binary files /dev/null and b/j8lib/groovy-json-4.0.15.jar differ diff --git a/j8lib/groovy-jsr223-4.0.15.jar b/j8lib/groovy-jsr223-4.0.15.jar new file mode 100644 index 0000000..5ae9f69 Binary files /dev/null and b/j8lib/groovy-jsr223-4.0.15.jar differ diff --git a/j8lib/groovy-macro-4.0.15.jar b/j8lib/groovy-macro-4.0.15.jar new file mode 100644 index 0000000..e5f7abb Binary files /dev/null and b/j8lib/groovy-macro-4.0.15.jar differ diff --git a/j8lib/groovy-macro-library-4.0.15.jar b/j8lib/groovy-macro-library-4.0.15.jar new file mode 100644 index 0000000..92c208f Binary files /dev/null and b/j8lib/groovy-macro-library-4.0.15.jar differ diff --git a/j8lib/groovy-nio-4.0.15.jar b/j8lib/groovy-nio-4.0.15.jar new file mode 100644 index 0000000..e6e2ad8 Binary files /dev/null and b/j8lib/groovy-nio-4.0.15.jar differ diff --git a/j8lib/groovy-servlet-4.0.15.jar b/j8lib/groovy-servlet-4.0.15.jar new file mode 100644 index 0000000..711a1e2 Binary files /dev/null and b/j8lib/groovy-servlet-4.0.15.jar differ diff --git a/j8lib/groovy-sql-4.0.15.jar b/j8lib/groovy-sql-4.0.15.jar new file mode 100644 index 0000000..058db44 Binary files /dev/null and b/j8lib/groovy-sql-4.0.15.jar differ diff --git a/j8lib/groovy-swing-4.0.15.jar b/j8lib/groovy-swing-4.0.15.jar new file mode 100644 index 0000000..848d074 Binary files /dev/null and b/j8lib/groovy-swing-4.0.15.jar differ diff --git a/j8lib/groovy-templates-4.0.15.jar b/j8lib/groovy-templates-4.0.15.jar new file mode 100644 index 0000000..3cd0245 Binary files /dev/null and b/j8lib/groovy-templates-4.0.15.jar differ diff --git a/j8lib/groovy-test-4.0.15.jar b/j8lib/groovy-test-4.0.15.jar new file mode 100644 index 0000000..e600dc7 Binary files /dev/null and b/j8lib/groovy-test-4.0.15.jar differ diff --git a/j8lib/groovy-test-junit5-4.0.15.jar b/j8lib/groovy-test-junit5-4.0.15.jar new file mode 100644 index 0000000..abcc69a Binary files /dev/null and b/j8lib/groovy-test-junit5-4.0.15.jar differ diff --git a/j8lib/groovy-testng-4.0.15.jar b/j8lib/groovy-testng-4.0.15.jar new file mode 100644 index 0000000..60c1b58 Binary files /dev/null and b/j8lib/groovy-testng-4.0.15.jar differ diff --git a/j8lib/groovy-toml-4.0.15.jar b/j8lib/groovy-toml-4.0.15.jar new file mode 100644 index 0000000..ad49634 Binary files /dev/null and b/j8lib/groovy-toml-4.0.15.jar differ diff --git a/j8lib/groovy-typecheckers-4.0.15.jar b/j8lib/groovy-typecheckers-4.0.15.jar new file mode 100644 index 0000000..dc113c3 Binary files /dev/null and b/j8lib/groovy-typecheckers-4.0.15.jar differ diff --git a/j8lib/groovy-xml-4.0.15.jar b/j8lib/groovy-xml-4.0.15.jar new file mode 100644 index 0000000..21aeea0 Binary files /dev/null and b/j8lib/groovy-xml-4.0.15.jar differ diff --git a/j8lib/groovy-yaml-4.0.15.jar b/j8lib/groovy-yaml-4.0.15.jar new file mode 100644 index 0000000..207d47d Binary files /dev/null and b/j8lib/groovy-yaml-4.0.15.jar differ diff --git a/j8lib/javaparser-core-3.25.5.jar b/j8lib/javaparser-core-3.25.5.jar new file mode 100644 index 0000000..92eed53 Binary files /dev/null and b/j8lib/javaparser-core-3.25.5.jar differ diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 58f9805..c3c8589 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1246,8 +1246,8 @@ label.mapping_method = Sequence \u27f7 Structure mapping method status.cancelled_image_export_operation = Cancelled {0} export operation info.error_creating_file = Error creating {0} file exception.outofmemory_loading_mmcif_file = Out of memory loading mmCIF File -label.run_groovy = Run Groovy console script -label.run_groovy_tip = Run the script in the Groovy console over this alignment +label.run_groovy = Run Groovy Console Script +label.run_groovy_tip = Run the script in the Groovy Console over this alignment label.couldnt_run_groovy_script = Failed to run Groovy script label.uniprot_sequence_fetcher = UniProt Sequence Fetcher action.next_page= >> diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 1abb171..483b1fc 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -54,6 +54,8 @@ import javax.swing.LookAndFeel; import javax.swing.UIManager; import jalview.analytics.Plausible; +import jalview.bin.argparser.Arg; +import jalview.bin.argparser.ArgParser; import jalview.datamodel.PDBEntry; import jalview.gui.Preferences; import jalview.gui.UserDefinedColours; @@ -1663,27 +1665,36 @@ public class Cache } if (file == null || !file.exists()) { + if (file != null) + { + jalview.bin.Console + .errPrintln("Could not load bootstrap preferences file '" + + file.getPath() + "'"); + } String channelPrefsFilename = ChannelProperties .getProperty("preferences.filename"); String propertiesFilename = System.getProperty("user.home") + File.separatorChar + channelPrefsFilename; + jalview.bin.Console.errPrintln( + "Using default properties file '" + propertiesFilename + "'"); file = new File(propertiesFilename); } if (file == null || !file.exists()) + { String releasePrefsFilename = fallbackPropertiesFile; String releasePropertiesFilename = System.getProperty("user.home") + File.separatorChar + releasePrefsFilename; + jalview.bin.Console.errPrintln("Falling back to properties file '" + + releasePropertiesFilename + "'"); file = new File(releasePropertiesFilename); } - if (filename == null) - return null; if (!file.exists()) { jalview.bin.Console .errPrintln("Could not load bootstrap preferences file '" - + filename + "'"); + + file.getPath() + "'"); return null; } @@ -1723,4 +1734,10 @@ public class Cache { return key == null ? null : sessionProperties.get(key); } + + public static boolean getArgCacheDefault(Arg a, String pref, boolean def) + { + ArgParser ap = Jalview.getInstance().getArgParser(); + return ap.isSet(a) ? ap.getBoolean(a) : getDefault(pref, def); + } } diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index 5d3b50d..e02d132 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -775,10 +775,11 @@ public class Commands // RESTORE SESSION AFTER EXPORT IF NEED BE if (sessionToRestore != null) { - Console.debug("Restoring session from " - + sessionToRestore); - - sview.getBinding().restoreSession(sessionToRestore.getAbsolutePath()); + Console.debug( + "Restoring session from " + sessionToRestore); + + sview.getBinding().restoreSession( + sessionToRestore.getAbsolutePath()); } } catch (ImageOutputException ioexec) @@ -789,11 +790,14 @@ public class Commands continue; } finally { - try { + try + { this.colourAlignFrame(af, originalColourScheme); } catch (Exception t) { - addError("Unexpected error when restoring colourscheme to alignment after temporary change for export.",t); + addError( + "Unexpected error when restoring colourscheme to alignment after temporary change for export.", + t); } } } @@ -838,21 +842,29 @@ public class Commands ArgValuesMap avm = argParser.getLinkedArgs(id); AlignFrame af = afMap.get(id); - if (af == null) + if (avm != null && !avm.containsArg(Arg.GROOVY)) { - addWarn("Did not have an alignment window for id=" + id); + // nothing to do return; } + if (af == null) + { + addWarn("Groovy script does not have an alignment window. Proceeding with caution!"); + } + if (avm.containsArg(Arg.GROOVY)) { - String groovyscript = avm.getValue(Arg.GROOVY); - if (groovyscript != null) + for (ArgValue groovyAv : avm.getArgValueList(Arg.GROOVY)) { - // Execute the groovy script after we've done all the rendering stuff - // and before any images or figures are generated. - Console.info("Executing script " + groovyscript); - Jalview.getInstance().executeGroovyScript(groovyscript, af); + String groovyscript = groovyAv.getValue(); + if (groovyscript != null) + { + // Execute the groovy script after we've done all the rendering stuff + // and before any images or figures are generated. + Console.info("Executing script " + groovyscript); + Jalview.getInstance().executeGroovyScript(groovyscript, af); + } } } } @@ -862,9 +874,16 @@ public class Commands ArgValuesMap avm = argParser.getLinkedArgs(id); AlignFrame af = afMap.get(id); + if (avm != null && !avm.containsArg(Arg.IMAGE)) + { + // nothing to do + return true; + } + if (af == null) { - addWarn("Did not have an alignment window for id=" + id); + addWarn("Do not have an alignment window to create image from (id=" + + id + "). Not proceeding."); return false; } @@ -991,9 +1010,16 @@ public class Commands ArgValuesMap avm = argParser.getLinkedArgs(id); AlignFrame af = afMap.get(id); + if (avm != null && !avm.containsArg(Arg.OUTPUT)) + { + // nothing to do + return true; + } + if (af == null) { - addWarn("Did not have an alignment window for id=" + id); + addWarn("Do not have an alignment window (id=" + id + + "). Not proceeding."); return false; } diff --git a/src/jalview/bin/Console.java b/src/jalview/bin/Console.java index 1b230ec..1bb8162 100644 --- a/src/jalview/bin/Console.java +++ b/src/jalview/bin/Console.java @@ -21,10 +21,8 @@ package jalview.bin; import java.io.PrintStream; -import java.util.Locale; import jalview.log.JLogger; -import jalview.log.JLoggerI; import jalview.log.JLoggerI.LogLevel; import jalview.log.JLoggerLog4j; import jalview.util.ChannelProperties; @@ -241,7 +239,7 @@ public class Console { JLogger.LogLevel logLevel = JLogger.LogLevel.INFO; - if (JLogger.isLevel(providedLogLevel)) + if (providedLogLevel != null && JLogger.isLevel(providedLogLevel)) { logLevel = Console.getLogLevel(providedLogLevel); } @@ -292,19 +290,23 @@ public class Console public static void setLogLevel(String logLevelString) { - for (LogLevel logLevel : JLoggerI.LogLevel.values()) + LogLevel l = null; + try + { + l = LogLevel.valueOf(logLevelString); + } catch (IllegalArgumentException | NullPointerException e1) + { + Console.debug("Invalid log level '" + logLevelString + "'"); + return; + } + if (l != null) { - if (logLevel.toString().toLowerCase(Locale.ROOT) - .equals(logLevelString.toLowerCase(Locale.ROOT))) + log.setLevel(l); + if (!Platform.isJS()) { - log.setLevel(logLevel); - if (!Platform.isJS()) - { - Log4j.init(logLevel); - } - JLoggerLog4j.getLogger("org.apache.axis", logLevel); - break; + Log4j.init(l); } + JLoggerLog4j.getLogger("org.apache.axis", l); } } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index b7d15e5..e343b0f 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -73,6 +73,8 @@ import jalview.bin.argparser.Arg.Opt; import jalview.bin.argparser.Arg.Type; import jalview.bin.argparser.ArgParser; import jalview.bin.argparser.BootstrapArgs; +import jalview.bin.groovy.JalviewObject; +import jalview.bin.groovy.JalviewObjectI; import jalview.ext.so.SequenceOntology; import jalview.gui.AlignFrame; import jalview.gui.Desktop; @@ -118,7 +120,7 @@ import jalview.ws.jws2.Jws2Discoverer; * @author $author$ * @version $Revision$ */ -public class Jalview +public class Jalview implements JalviewObjectI { static { @@ -138,7 +140,7 @@ public class Jalview protected Commands cmds; - public static AlignFrame currentAlignFrame; + public AlignFrame currentAlignFrame = null; private ArgParser argparser = null; @@ -447,7 +449,7 @@ public class Jalview } else if (bootstrapArgs.contains(Arg.DEBUG)) { - logLevel = "DEBUG"; + logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO"; } if (logLevel == null && !(bootstrapProperties == null)) { @@ -642,14 +644,12 @@ public class Jalview try { Console.initLogger(); - } catch ( - - NoClassDefFoundError error) + } catch (NoClassDefFoundError error) { error.printStackTrace(); String message = "\nEssential logging libraries not found." + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview"; - Jalview.exit(message, ExitCode.OK); + Jalview.exit(message, ExitCode.NO_LOGGING); } desktop = null; @@ -1633,8 +1633,7 @@ public class Jalview PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop, "USAGESTATS", MessageManager.getString("prompt.analytics_title"), - MessageManager.getString("prompt.analytics"), - new Runnable() + MessageManager.getString("prompt.analytics"), new Runnable() { @Override public void run() @@ -1752,12 +1751,11 @@ public class Jalview } try { + JalviewObjectI j = new JalviewObject(this); Map vbinding = new HashMap<>(); - vbinding.put("Jalview", this); - if (af != null) - { - vbinding.put("currentAlFrame", af); - } + vbinding.put(JalviewObjectI.jalviewObjectName, j); + vbinding.put(JalviewObjectI.currentAlFrameName, + af != null ? af : getCurrentAlignFrame()); Binding gbinding = new Binding(vbinding); GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile }); gse.run(sfile.toString(), gbinding); @@ -1773,7 +1771,6 @@ public class Jalview .errPrintln("Exception Whilst trying to execute file " + sfile + " as a groovy script."); e.printStackTrace(System.err); - } } @@ -1787,30 +1784,32 @@ public class Jalview return false; } + @Override public AlignFrame[] getAlignFrames() { return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() } - : Desktop.getAlignFrames(); - + : Desktop.getDesktopAlignFrames(); } /** * jalview.bin.Jalview.quit() will just run the non-GUI shutdownHook and exit */ + @Override public void quit() { // System.exit will run the shutdownHook first Jalview.exit("Quitting now. Bye!", ExitCode.OK); } - public static AlignFrame getCurrentAlignFrame() + @Override + public AlignFrame getCurrentAlignFrame() { - return Jalview.currentAlignFrame; + return currentAlignFrame; } - public static void setCurrentAlignFrame(AlignFrame currentAlignFrame) + public void setCurrentAlignFrame(AlignFrame af) { - Jalview.currentAlignFrame = currentAlignFrame; + this.currentAlignFrame = af; } public Commands getCommands() @@ -1862,7 +1861,7 @@ public class Jalview // only add new ones to the end of the list (to preserve ordinal values) OK, FILE_NOT_FOUND, FILE_NOT_READABLE, NO_FILES, INVALID_FORMAT, INVALID_ARGUMENT, INVALID_VALUE, MIXED_CLI_ARGUMENTS, - ERROR_RUNNING_COMMANDS; + ERROR_RUNNING_COMMANDS, NO_LOGGING, GROOVY_ERROR; } /****************************** @@ -2041,8 +2040,8 @@ public class Jalview j.getArgParser().getMixedExamples()); String quit = MessageManager.getString("action.quit"); - Desktop.instance.nonBlockingDialog(title, warning, quit, - JvOptionPane.WARNING_MESSAGE, false, true); + Desktop.instance.nonBlockingDialog(title, warning, null, quit, + JvOptionPane.WARNING_MESSAGE, false, false, true, 30000); Jalview.exit( "Exiting due to mixed old and new command line arguments.", @@ -2066,8 +2065,8 @@ public class Jalview { String cont = MessageManager.getString("label.continue"); - Desktop.instance.nonBlockingDialog(32, 2, title, warning, url, cont, - JvOptionPane.WARNING_MESSAGE, false, true, true); + Desktop.instance.nonBlockingDialog(title, warning, url, cont, + JvOptionPane.WARNING_MESSAGE, false, true, true, 30000); } } if (j.getCommands() != null && j.getCommands().getErrors().size() > 0) @@ -2087,7 +2086,7 @@ public class Jalview Math.max(message.length(), Math.min(60, shortest)), Math.min(errors.size(), 20), title, message, j.getCommands().errorsToString(), ok, - JvOptionPane.WARNING_MESSAGE, true, false, true); + JvOptionPane.WARNING_MESSAGE, true, false, true, -1); } } } diff --git a/src/jalview/bin/argparser/Arg.java b/src/jalview/bin/argparser/Arg.java index 2a3a4a1..93156ac 100644 --- a/src/jalview/bin/argparser/Arg.java +++ b/src/jalview/bin/argparser/Arg.java @@ -44,6 +44,8 @@ public enum Arg QUESTIONNAIRE(Type.CONFIG, "Show (or don't show) the questionnaire if one is available.", true, Opt.BOOLEAN, Opt.BOOTSTRAP), + JAVACONSOLE(Type.CONFIG, "Show (or don't show) the Java Console.", false, + Opt.BOOLEAN, Opt.BOOTSTRAP), NOUSAGESTATS(Type.CONFIG, "Don't send initial launch usage stats.", Opt.UNARY, Opt.BOOTSTRAP), NOSTARTUPFILE(Type.CONFIG, "Don't show the default startup file.", diff --git a/src/jalview/bin/argparser/ArgParser.java b/src/jalview/bin/argparser/ArgParser.java index 1b8e6ad..155f69e 100644 --- a/src/jalview/bin/argparser/ArgParser.java +++ b/src/jalview/bin/argparser/ArgParser.java @@ -318,9 +318,13 @@ public class ArgParser } if (bsa != null) + { this.bootstrapArgs = bsa; + } else + { this.bootstrapArgs = BootstrapArgs.getBootstrapArgs(args); + } parse(args, initsubstitutions, allowPrivate); } diff --git a/src/jalview/bin/argparser/BootstrapArgs.java b/src/jalview/bin/argparser/BootstrapArgs.java index d32a5b2..5c21d03 100644 --- a/src/jalview/bin/argparser/BootstrapArgs.java +++ b/src/jalview/bin/argparser/BootstrapArgs.java @@ -214,6 +214,13 @@ public class BootstrapArgs } } } + + // if in an argfile, remove it from the hashset so it can be re-used in + // another argfile + if (inArgFile != null) + { + argFiles.remove(inArgFile); + } } public boolean contains(Arg a) diff --git a/src/jalview/bin/groovy/JalviewObject.java b/src/jalview/bin/groovy/JalviewObject.java new file mode 100644 index 0000000..e271c3c --- /dev/null +++ b/src/jalview/bin/groovy/JalviewObject.java @@ -0,0 +1,42 @@ +package jalview.bin.groovy; + +import jalview.bin.Jalview.ExitCode; +import jalview.gui.AlignFrame; + +public class JalviewObject implements JalviewObjectI +{ + private JalviewObjectI object = null; + + public JalviewObject(JalviewObjectI j) + { + this.object = j; + } + + @Override + public AlignFrame[] getAlignFrames() + { + return object == null ? null : object.getAlignFrames(); + } + + @Override + public AlignFrame getCurrentAlignFrame() + { + return object == null ? null : object.getCurrentAlignFrame(); + } + + @Override + public void quit() + { + if (object != null) + { + object.quit(); + } + else + { + jalview.bin.Jalview.exit( + "Groovy console quit without Jalview object.", + ExitCode.GROOVY_ERROR); + } + } + +} diff --git a/src/jalview/bin/groovy/JalviewObjectI.java b/src/jalview/bin/groovy/JalviewObjectI.java new file mode 100644 index 0000000..f365d30 --- /dev/null +++ b/src/jalview/bin/groovy/JalviewObjectI.java @@ -0,0 +1,16 @@ +package jalview.bin.groovy; + +import jalview.gui.AlignFrame; + +public interface JalviewObjectI +{ + public AlignFrame[] getAlignFrames(); + + public AlignFrame getCurrentAlignFrame(); + + public final static String currentAlFrameName = "currentAlFrame"; + + public final static String jalviewObjectName = "Jalview"; + + public void quit(); +} diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index f3cb012..ac8ffb9 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -95,6 +95,7 @@ import jalview.api.analysis.SimilarityParamsI; import jalview.bin.Cache; import jalview.bin.Console; import jalview.bin.Jalview; +import jalview.bin.groovy.JalviewObjectI; import jalview.commands.CommandI; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; @@ -503,7 +504,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void focusGained(FocusEvent e) { - Jalview.setCurrentAlignFrame(AlignFrame.this); + Jalview.getInstance().setCurrentAlignFrame(AlignFrame.this); } }); @@ -5963,12 +5964,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override protected void runGroovy_actionPerformed() { - Jalview.setCurrentAlignFrame(this); - groovy.ui.Console console = Desktop.getGroovyConsole(); + Jalview.getInstance().setCurrentAlignFrame(this); + groovy.console.ui.Console console = Desktop.getGroovyConsole(); if (console != null) { try { + console.setVariable(JalviewObjectI.currentAlFrameName, this); console.runScript(); } catch (Exception ex) { diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index ef9e575..a8bc815 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -997,7 +997,7 @@ public class AlignViewport extends AlignmentViewport */ protected boolean noReferencesTo(AlignedCodonFrame acf) { - AlignFrame[] frames = Desktop.getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); if (frames == null) { return true; diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index 89380a3..921a418 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -107,7 +107,7 @@ public class Console extends WindowAdapter private JComboBox logLevelCombo = new JComboBox(); - protected LogLevel startingLogLevel = LogLevel.INFO; + protected LogLevel startingLogLevel = null; public Console() { @@ -148,6 +148,7 @@ public class Console extends WindowAdapter scrollPane.setBorder(noBorder); textArea.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) @@ -173,6 +174,7 @@ public class Console extends WindowAdapter MessageManager.getString("label.copy_to_clipboard")); copyToClipboardButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { copyConsoleTextToClipboard(); @@ -184,12 +186,14 @@ public class Console extends WindowAdapter private Color fg = textArea.getForeground(); + @Override public void mousePressed(MouseEvent e) { textArea.setBackground(textArea.getSelectionColor()); textArea.setForeground(textArea.getSelectedTextColor()); } + @Override public void mouseReleased(MouseEvent e) { textArea.setBackground(bg); @@ -213,11 +217,19 @@ public class Console extends WindowAdapter // logLevelCombo.addItem(LogLevel.ERROR); // logLevelCombo.addItem(LogLevel.OFF); // set startingLogLevel - startingLogLevel = jalview.bin.Console.log == null ? LogLevel.INFO - : jalview.bin.Console.log.getLevel(); + + if (jalview.bin.Console.getLogger() == null) + { + startingLogLevel = jalview.bin.Console.getCachedLogLevel(); + } + else + { + startingLogLevel = jalview.bin.Console.getLogger().getLevel(); + } setChosenLogLevelCombo(); logLevelCombo.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (jalview.bin.Console.log != null) @@ -314,7 +326,7 @@ public class Console extends WindowAdapter boolean added = false; for (int i = 0; i < logLevelCombo.getItemCount(); i++) { - LogLevel l = (LogLevel) logLevelCombo.getItemAt(i); + LogLevel l = logLevelCombo.getItemAt(i); if (l.compareTo(setLogLevel) >= 0) { logLevelCombo.insertItemAt(setLogLevel, i); @@ -476,36 +488,32 @@ public class Console extends WindowAdapter */ public Console(Desktop desktop) { - this(desktop, true); - } - - /** - * attach a console to the desktop - the desktop will open it if requested. - * - * @param desktop - * @param showjconsole - * - if true, then redirect stdout immediately - */ - public Console(Desktop desktop, boolean showjconsole) - { parent = desktop; // window name - get x,y,width, height possibly scaled - Rectangle bounds = desktop.getLastKnownDimensions("JAVA_CONSOLE_"); - if (bounds == null) + Rectangle bounds = parent == null ? null + : parent.getLastKnownDimensions("JAVA_CONSOLE_"); + if (bounds != null) { frame = initFrame( ChannelProperties.getProperty("app_name") + " Java Console", - desktop.getWidth() / 2, desktop.getHeight() / 4, - desktop.getX(), desktop.getY()); + bounds.width, bounds.height, bounds.x, bounds.y); + } + else if (parent != null && parent.getWidth() > 0 + && parent.getHeight() > 0) + { + frame = initFrame( + ChannelProperties.getProperty("app_name") + " Java Console", + parent.getWidth() / 2, parent.getHeight() / 4, parent.getX(), + parent.getY()); } else { frame = initFrame( ChannelProperties.getProperty("app_name") + " Java Console", - bounds.width, bounds.height, bounds.x, bounds.y); + MIN_WIDTH, MIN_HEIGHT, 10, 10); } frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT)); - // desktop.add(frame); + // parent.add(frame); initConsole(false); LogLevel level = (LogLevel) logLevelCombo.getSelectedItem(); if (!Platform.isJS()) @@ -538,6 +546,7 @@ public class Console extends WindowAdapter pin.close(); } catch (Exception e) { + jalview.bin.Console.debug("pin.close() error", e); } try { @@ -545,12 +554,14 @@ public class Console extends WindowAdapter pin2.close(); } catch (Exception e) { + jalview.bin.Console.debug("pin2.close() error", e); } try { textAppender.join(10); } catch (Exception e) { + jalview.bin.Console.debug("textAppender.join(10) error", e); } } /* @@ -611,12 +622,9 @@ public class Console extends WindowAdapter try { this.wait(100); -// if (pin.available() == 0) -// { -// trimBuffer(false); -// } } catch (InterruptedException ie) { + jalview.bin.Console.debug("pin.available() error", ie); } } @@ -642,13 +650,14 @@ public class Console extends WindowAdapter { try { - this.wait(100); + this.wait(100); // ##### implicated BLOCKED if (pin2.available() == 0) { trimBuffer(false); } } catch (InterruptedException ie) { + jalview.bin.Console.debug("pin.available() error", ie); } } while (pin2.available() != 0) @@ -689,7 +698,7 @@ public class Console extends WindowAdapter textArea.append(replace.toString()); trimBuffer(false); } - }); + }); } if (displayPipe.length() == 0) { @@ -709,6 +718,7 @@ public class Console extends WindowAdapter } } catch (InterruptedException e) { + jalview.bin.Console.debug("displayPipe.length() error", e); } } } @@ -719,7 +729,7 @@ public class Console extends WindowAdapter this.wait(100); } catch (InterruptedException e) { - + jalview.bin.Console.debug("this.wait(100) error", e); } } if (quit) @@ -746,6 +756,7 @@ public class Console extends WindowAdapter this.wait(1000); } catch (InterruptedException ie) { + jalview.bin.Console.debug("this.wait(1000) error", ie); } throw new NullPointerException( MessageManager.getString("exception.application_test_npe")); @@ -787,7 +798,7 @@ public class Console extends WindowAdapter + "\nTruncated...\n"; } catch (Exception e) { - e.printStackTrace(); + jalview.bin.Console.warn("textArea Exception", e); } } // trim the buffer @@ -811,7 +822,7 @@ public class Console extends WindowAdapter } } catch (Exception e) { - e.printStackTrace(); + jalview.bin.Console.warn("textArea Exception", e); } // lines = textArea.getLineCount(); } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index e785431..35afb69 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -113,6 +113,9 @@ import jalview.api.structures.JalviewStructureDisplayI; import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.bin.Jalview.ExitCode; +import jalview.bin.argparser.Arg; +import jalview.bin.groovy.JalviewObject; +import jalview.bin.groovy.JalviewObjectI; import jalview.datamodel.Alignment; import jalview.datamodel.HiddenColumns; import jalview.datamodel.Sequence; @@ -157,7 +160,7 @@ import jalview.ws.utils.UrlDownloadClient; */ public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener, ClipboardOwner, IProgressIndicator, - jalview.api.StructureSelectionManagerProvider + jalview.api.StructureSelectionManagerProvider, JalviewObjectI { private static final String CITATION; static @@ -498,7 +501,28 @@ public class Desktop extends jalview.jbgui.GDesktop boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE", false); - boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE", false); + boolean showjconsole = Cache.getArgCacheDefault(Arg.JAVACONSOLE, + "SHOW_JAVA_CONSOLE", false); + + // start dialogue queue for single dialogues + startDialogQueue(); + + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + */ + { + Desktop.instance.acquireDialogQueue(); + + jconsole = new Console(this); + jconsole.setHeader(Cache.getVersionDetailsForConsole()); + showConsole(showjconsole); + + Desktop.instance.releaseDialogQueue(); + } + desktop = new MyDesktopPane(selmemusage); showMemusage.setSelected(selmemusage); @@ -545,9 +569,6 @@ public class Desktop extends jalview.jbgui.GDesktop setBounds(xPos, yPos, 900, 650); } - // start dialogue queue for single dialogues - startDialogQueue(); - if (!Platform.isJS()) /** * Java only @@ -555,10 +576,6 @@ public class Desktop extends jalview.jbgui.GDesktop * @j2sIgnore */ { - jconsole = new Console(this, showjconsole); - jconsole.setHeader(Cache.getVersionDetailsForConsole()); - showConsole(showjconsole); - showNews.setVisible(false); experimentalFeatures.setSelected(showExperimental()); @@ -787,17 +804,17 @@ public class Desktop extends jalview.jbgui.GDesktop iw = (int) (iw * sw); iy = (int) (iy * sh); ih = (int) (ih * sh); - while (ix >= screenSize.width) + if (ix >= screenSize.width) { jalview.bin.Console.debug( "Window geometry location recall error: shifting horizontal to within screenbounds."); - ix -= screenSize.width; + ix = ix % screenSize.width; } - while (iy >= screenSize.height) + if (iy >= screenSize.height) { jalview.bin.Console.debug( "Window geometry location recall error: shifting vertical to within screenbounds."); - iy -= screenSize.height; + iy = iy % screenSize.height; } jalview.bin.Console.debug( "Got last known dimensions for " + windowName + ": x:" + ix @@ -1041,7 +1058,7 @@ public class Desktop extends jalview.jbgui.GDesktop { if (itf instanceof AlignFrame) { - Jalview.setCurrentAlignFrame((AlignFrame) itf); + Jalview.getInstance().setCurrentAlignFrame((AlignFrame) itf); } itf.requestFocus(); } @@ -1460,62 +1477,73 @@ public class Desktop extends jalview.jbgui.GDesktop desktopQuit(true, false); } - public QuitHandler.QResponse desktopQuit(boolean ui, boolean disposeFlag) - { - final Runnable doDesktopQuit = () -> { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Cache.setProperty("SCREENGEOMETRY_WIDTH", screen.width + ""); - Cache.setProperty("SCREENGEOMETRY_HEIGHT", screen.height + ""); - storeLastKnownDimensions("", new Rectangle(getBounds().x, - getBounds().y, getWidth(), getHeight())); + /** + * close everything, stash window geometries, and shut down all associated threads/workers + * @param dispose - sets the dispose on close flag - JVM may terminate when set + * @param terminateJvm - quit with prejudice - stops the JVM. + */ + public void quitTheDesktop(boolean dispose, boolean terminateJvm) { + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + Cache.setProperty("SCREENGEOMETRY_WIDTH", screen.width + ""); + Cache.setProperty("SCREENGEOMETRY_HEIGHT", screen.height + ""); + storeLastKnownDimensions("", new Rectangle(getBounds().x, + getBounds().y, getWidth(), getHeight())); - if (jconsole != null) - { - storeLastKnownDimensions("JAVA_CONSOLE_", jconsole.getBounds()); - jconsole.stopConsole(); - } + if (jconsole != null) + { + storeLastKnownDimensions("JAVA_CONSOLE_", jconsole.getBounds()); + jconsole.stopConsole(); + } - if (jvnews != null) - { - storeLastKnownDimensions("JALVIEW_RSS_WINDOW_", jvnews.getBounds()); - } + if (jvnews != null) + { + storeLastKnownDimensions("JALVIEW_RSS_WINDOW_", jvnews.getBounds()); + } - // Frames should all close automatically. Keeping external - // viewers open should already be decided by user. - closeAll_actionPerformed(null); + // Frames should all close automatically. Keeping external + // viewers open should already be decided by user. + closeAll_actionPerformed(null); - // check for aborted quit - if (QuitHandler.quitCancelled()) - { - jalview.bin.Console.debug("Desktop aborting quit"); - return; - } + if (dialogExecutor != null) + { + dialogExecutor.shutdownNow(); + } - if (dialogExecutor != null) - { - dialogExecutor.shutdownNow(); - } + if (groovyConsole != null) + { + // suppress a possible repeat prompt to save script + groovyConsole.setDirty(false); + groovyConsole.exit(); + } - if (groovyConsole != null) - { - // suppress a possible repeat prompt to save script - groovyConsole.setDirty(false); - groovyConsole.exit(); - } + if (terminateJvm) + { + // note that shutdown hook will not be run + jalview.bin.Console.debug("Force Quit selected by user"); + Runtime.getRuntime().halt(0); + } - if (QuitHandler.gotQuitResponse() == QResponse.FORCE_QUIT) - { - // note that shutdown hook will not be run - jalview.bin.Console.debug("Force Quit selected by user"); - Runtime.getRuntime().halt(0); - } + jalview.bin.Console.debug("Quit selected by user"); + if (dispose) + { + instance.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + // instance.dispose(); + } + } + public QuitHandler.QResponse desktopQuit(boolean ui, boolean disposeFlag) + { + final Runnable doDesktopQuit = () -> { - jalview.bin.Console.debug("Quit selected by user"); - if (disposeFlag) + // FIRST !! check for aborted quit + if (QuitHandler.quitCancelled()) { - instance.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - // instance.dispose(); + jalview.bin.Console.debug("Quit was cancelled - Desktop aborting quit"); + return; } + + // Proceed with quitting + quitTheDesktop(disposeFlag, QuitHandler.gotQuitResponse() == QResponse.FORCE_QUIT); + // and exit the JVM instance.quit(); }; @@ -1524,7 +1552,14 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * Don't call this directly, use desktopQuit() above. Exits the program. + * Exits the program and the JVM. + * + * Don't call this directly + * + * - use desktopQuit() above to tidy up first. + * + * - use closeDesktop() to shutdown Jalview without shutting down the JVM + * */ @Override public void quit() @@ -1664,7 +1699,7 @@ public class Desktop extends jalview.jbgui.GDesktop { } } - Jalview.setCurrentAlignFrame(null); + Jalview.getInstance().setCurrentAlignFrame(null); jalview.bin.Console.info("ALL CLOSED"); /* @@ -2123,7 +2158,7 @@ public class Desktop extends jalview.jbgui.GDesktop return null; } List aps = new ArrayList<>(); - AlignFrame[] frames = getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); if (frames == null) { return null; @@ -2160,7 +2195,7 @@ public class Desktop extends jalview.jbgui.GDesktop List viewp = new ArrayList<>(); if (desktop != null) { - AlignFrame[] frames = Desktop.getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); for (AlignFrame afr : frames) { @@ -2521,12 +2556,12 @@ public class Desktop extends jalview.jbgui.GDesktop * * @return an array of AlignFrame, or null if none found */ - public static AlignFrame[] getAlignFrames() + @Override + public AlignFrame[] getAlignFrames() { - if (Jalview.isHeadlessMode()) + if (desktop == null) { - // Desktop.desktop is null in headless mode - return new AlignFrame[] { Jalview.currentAlignFrame }; + return null; } JInternalFrame[] frames = Desktop.desktop.getAllFrames(); @@ -2568,6 +2603,25 @@ public class Desktop extends jalview.jbgui.GDesktop } /** + * static version + */ + public static AlignFrame[] getDesktopAlignFrames() + { + if (Jalview.isHeadlessMode()) + { + // Desktop.desktop is null in headless mode + return Jalview.getInstance().getAlignFrames(); + } + + if (instance != null && desktop != null) + { + return instance.getAlignFrames(); + } + + return null; + } + + /** * Returns an array of any AppJmol frames in the Desktop (or null if none). * * @return @@ -2609,7 +2663,7 @@ public class Desktop extends jalview.jbgui.GDesktop openGroovyConsole(); } catch (Exception ex) { - jalview.bin.Console.error("Groovy Shell Creation failed.", ex); + jalview.bin.Console.error("Groovy Console creation failed.", ex); JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager.getString("label.couldnt_create_groovy_shell"), @@ -2625,8 +2679,11 @@ public class Desktop extends jalview.jbgui.GDesktop { if (groovyConsole == null) { - groovyConsole = new groovy.ui.Console(); - groovyConsole.setVariable("Jalview", this); + JalviewObjectI j = new JalviewObject(this); + groovyConsole = new groovy.console.ui.Console(); + groovyConsole.setVariable(JalviewObjectI.jalviewObjectName, j); + groovyConsole.setVariable(JalviewObjectI.currentAlFrameName, + getCurrentAlignFrame()); groovyConsole.run(); /* @@ -2699,7 +2756,7 @@ public class Desktop extends jalview.jbgui.GDesktop */ groovyShell.setEnabled(!enabled); - AlignFrame[] alignFrames = getAlignFrames(); + AlignFrame[] alignFrames = getDesktopAlignFrames(); if (alignFrames != null) { for (AlignFrame af : alignFrames) @@ -3108,7 +3165,7 @@ public class Desktop extends jalview.jbgui.GDesktop */ private Semaphore block = new Semaphore(0); - private static groovy.ui.Console groovyConsole; + private static groovy.console.ui.Console groovyConsole; /** * add another dialog thread to the queue @@ -3370,7 +3427,7 @@ public class Desktop extends jalview.jbgui.GDesktop myTopFrame.setDisplayedView(myTopFrame.alignPanel); } - public static groovy.ui.Console getGroovyConsole() + public static groovy.console.ui.Console getGroovyConsole() { return groovyConsole; } @@ -3661,32 +3718,34 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * closes the current instance window, disposes and forgets about it. + * closes the current instance window, but leaves the JVM running. + * Bypasses any shutdown prompts, but does not set window dispose on close in case JVM terminates. */ public static void closeDesktop() { if (Desktop.instance != null) { - Desktop.instance.closeAll_actionPerformed(null); - Desktop.instance.setVisible(false); Desktop us = Desktop.instance; - Desktop.instance = null; + Desktop.instance.quitTheDesktop(false, false); // call dispose in a separate thread - try to avoid indirect deadlocks - new Thread(new Runnable() + if (us != null) { - @Override - public void run() + new Thread(new Runnable() { - ExecutorService dex = us.dialogExecutor; - if (dex != null) + @Override + public void run() { - dex.shutdownNow(); - us.dialogExecutor = null; - us.block.drainPermits(); + ExecutorService dex = us.dialogExecutor; + if (dex != null) + { + dex.shutdownNow(); + us.dialogExecutor = null; + us.block.drainPermits(); + } + us.dispose(); } - us.dispose(); - } - }).start(); + }).start(); + } } } @@ -3747,13 +3806,21 @@ public class Desktop extends jalview.jbgui.GDesktop public void nonBlockingDialog(String title, String message, String button, int type, boolean scrollable, boolean modal) { - nonBlockingDialog(32, 2, title, message, null, button, type, scrollable, - false, modal); + nonBlockingDialog(title, message, null, button, type, scrollable, false, + modal, -1); + } + + public void nonBlockingDialog(String title, String message, + String boxtext, String button, int type, boolean scrollable, + boolean html, boolean modal, int timeout) + { + nonBlockingDialog(32, 2, title, message, boxtext, button, type, + scrollable, html, modal, timeout); } public void nonBlockingDialog(int width, int height, String title, String message, String boxtext, String button, int type, - boolean scrollable, boolean html, boolean modal) + boolean scrollable, boolean html, boolean modal, int timeout) { if (type < 0) { @@ -3815,9 +3882,16 @@ public class Desktop extends jalview.jbgui.GDesktop jvp.setResponseHandler(JOptionPane.YES_OPTION, () -> { }); + jvp.setTimeout(timeout); + JButton jb = new JButton(button); jvp.showDialogOnTopAsync(this, jp, title, JOptionPane.YES_OPTION, type, null, new Object[] - { button }, button, modal, null, false); + { button }, button, modal, new JButton[] { jb }, false); } + @Override + public AlignFrame getCurrentAlignFrame() + { + return Jalview.getInstance().getCurrentAlignFrame(); + } } diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 184fdc5..4d31805 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1787,11 +1787,15 @@ public class FeatureSettings extends JPanel { FeatureMatcherSetI theFilter = (FeatureMatcherSetI) filter; setOpaque(true); - String asText = theFilter.toString(); setBackground(tbl.getBackground()); - this.setText(asText); this.setIcon(null); + if (theFilter != null) + { + String asText = theFilter.toString(); + this.setText(asText); + } + if (isSelected) { if (selectedBorder == null) diff --git a/src/jalview/gui/JvOptionPane.java b/src/jalview/gui/JvOptionPane.java index 3f5de0a..7a5daf7 100644 --- a/src/jalview/gui/JvOptionPane.java +++ b/src/jalview/gui/JvOptionPane.java @@ -88,6 +88,13 @@ public class JvOptionPane extends JOptionPane private Map callbacks = new HashMap<>(); + private int timeout = -1; + + public void setTimeout(int i) + { + timeout = i; + } + /* * JalviewJS reports user choice in the dialog as the selected option (text); * this list allows conversion to index (int) @@ -851,6 +858,42 @@ public class JvOptionPane extends JOptionPane "Supplied buttons array not the same length as supplied options array."); break NOTNULL; } + + // run through buttons for initialValue first so we can set (and start) + // a final timeoutThreadF to include (and interrupt) in the button + // actions + Thread timeoutThread = null; + for (int i = 0; i < options.length; i++) + { + Object o = options[i]; + JButton jb = buttons[i]; + if (o.equals(initialValue)) + { + if (timeout > 0 && jb != null && jb instanceof JButton) + { + // after timeout ms click the default button + timeoutThread = new Thread(() -> { + try + { + Thread.sleep(timeout); + } catch (InterruptedException e) + { + Console.debug( + "Dialog timeout interrupted. Probably a button pressed."); + } + jb.doClick(); + }); + } + initialValueButton = jb; + break; + } + } + final Thread timeoutThreadF = timeoutThread; + if (timeoutThreadF != null) + { + timeoutThreadF.start(); + } + int[] buttonActions = { JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, JOptionPane.CANCEL_OPTION }; for (int i = 0; i < options.length; i++) @@ -860,9 +903,6 @@ public class JvOptionPane extends JOptionPane "Setting button " + i + " to '" + o.toString() + "'"); JButton jb = buttons[i]; - if (o.equals(initialValue)) - initialValueButton = jb; - int buttonAction = buttonActions[i]; Runnable action = callbacks.get(buttonAction); jb.setText((String) o); @@ -871,6 +911,10 @@ public class JvOptionPane extends JOptionPane @Override public void actionPerformed(ActionEvent e) { + if (timeoutThreadF != null) + { + timeoutThreadF.interrupt(); + } Object obj = e.getSource(); if (obj == null || !(obj instanceof Component)) @@ -1290,6 +1334,7 @@ public class JvOptionPane extends JOptionPane // A better hack which works is to create a new JFrame parent with // setAlwaysOnTop(true) + boolean parentOnTop = dialogParent.isAlwaysOnTop(); dialogParent.setAlwaysOnTop(true); parentComponent = dialogParent; @@ -1297,6 +1342,8 @@ public class JvOptionPane extends JOptionPane JOPTIONPANE_MESSAGETYPE, icon, options, initialValue, modal, buttons); + dialogParent.setAlwaysOnTop(parentOnTop); + if (dispose) { dialogParent.setAlwaysOnTop(false); diff --git a/src/jalview/gui/QuitHandler.java b/src/jalview/gui/QuitHandler.java index ad7684e..6020135 100644 --- a/src/jalview/gui/QuitHandler.java +++ b/src/jalview/gui/QuitHandler.java @@ -294,7 +294,7 @@ public class QuitHandler return QResponse.QUIT; int size = 0; - AlignFrame[] afArray = Desktop.getAlignFrames(); + AlignFrame[] afArray = Desktop.getDesktopAlignFrames(); if (!(afArray == null || afArray.length == 0)) { for (int i = 0; i < afArray.length; i++) diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 52c1d18..1060d8a 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -342,7 +342,7 @@ public class SplashScreen extends JPanel try { - iframe.setClosed(true); + iframe.setClosed(true); // ##### implicated BLOCKED } catch (Exception ex) { } diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index 196eb32..d8259f9 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -1325,7 +1325,7 @@ public class WsJobParameters extends JPanel implements ItemListener, */ protected void updateWebServiceMenus() { - for (AlignFrame alignFrame : Desktop.getAlignFrames()) + for (AlignFrame alignFrame : Desktop.getDesktopAlignFrames()) { alignFrame.BuildWebServiceMenu(); } diff --git a/src/jalview/io/DataSourceType.java b/src/jalview/io/DataSourceType.java index 6d00a7d..c983dfe 100644 --- a/src/jalview/io/DataSourceType.java +++ b/src/jalview/io/DataSourceType.java @@ -28,4 +28,9 @@ public enum DataSourceType { return this != FILE; } + + public boolean isUrl() + { + return this == URL || this == RELATIVE_URL; + } } diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index dc7adac..b16c37f 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -361,8 +361,9 @@ public class FileLoader implements Runnable // We read the data anyway - it might make sense. } // BH 2018 switch to File object here instead of filename - alignFrame = new Jalview2XML(raiseGUI && !Jalview.isBatchMode()).loadJalviewAlign( - selectedFile == null ? file : selectedFile); + alignFrame = new Jalview2XML(raiseGUI && !Jalview.isBatchMode()) + .loadJalviewAlign( + selectedFile == null ? file : selectedFile); } else { @@ -563,7 +564,8 @@ public class FileLoader implements Runnable } catch (Exception er) { - jalview.bin.Console.errPrintln("Exception whilst opening file '" + file); + jalview.bin.Console + .errPrintln("Exception whilst opening file '" + file); er.printStackTrace(); if (raiseGUI && !Jalview.isBatchMode()) { @@ -603,7 +605,8 @@ public class FileLoader implements Runnable } }); } - jalview.bin.Console.errPrintln("Out of memory loading file " + file + "!!"); + jalview.bin.Console + .errPrintln("Out of memory loading file " + file + "!!"); } loadtime += System.currentTimeMillis(); @@ -684,10 +687,18 @@ public class FileLoader implements Runnable AlignViewport avp = af.getViewport(); if (avp == null) return; - avp.setSavedUpToDate(!protocol.isDynamic(), - QuitHandler.Message.UNSAVED_ALIGNMENTS); + boolean upToDate = !protocol.isDynamic(); + if (protocol.isUrl() && !Cache + .getDefault(PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS, true)) + { + upToDate = true; + } + avp.setSavedUpToDate(upToDate, + upToDate ? null : QuitHandler.Message.UNSAVED_ALIGNMENTS); } + public static final String PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS = "PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS"; + public static boolean getUseDefaultFileFormat() { return useDefaultFileFormat; diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 721cd47..0a1172c 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -55,7 +55,7 @@ public class SequenceAnnotationReport private static final int MAX_REFS_PER_SOURCE = 4; - private static final int MAX_SOURCES = 40; + private static final int MAX_SOURCES = 5; private static String linkImageURL; @@ -79,10 +79,19 @@ public class SequenceAnnotationReport { return 1; } + String s1 = ref1.getSource(); String s2 = ref2.getSource(); boolean s1Primary = DBRefSource.isPrimarySource(s1); boolean s2Primary = DBRefSource.isPrimarySource(s2); + if (ref1.isCanonical() && !ref2.isCanonical()) + { + return -1; + } + if (!ref1.isCanonical() && ref2.isCanonical()) + { + return 1; + } if (s1Primary && !s2Primary) { return -1; diff --git a/src/jalview/io/VamsasAppDatastore.java b/src/jalview/io/VamsasAppDatastore.java index c3776d3..46b75c8 100644 --- a/src/jalview/io/VamsasAppDatastore.java +++ b/src/jalview/io/VamsasAppDatastore.java @@ -151,7 +151,7 @@ public class VamsasAppDatastore private void buildSkipList() { skipList = new Hashtable(); - AlignFrame[] al = Desktop.getAlignFrames(); + AlignFrame[] al = Desktop.getDesktopAlignFrames(); for (int f = 0; al != null && f < al.length; f++) { skipList.put(al[f].getViewport().getSequenceSetId(), al[f]); diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index af3b2c8..cc20fce 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -631,7 +631,7 @@ public class Jalview2XML */ public void saveState(JarOutputStream jout) { - AlignFrame[] frames = Desktop.getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); setStateSavedUpToDate(true); @@ -6919,7 +6919,7 @@ public class Jalview2XML if (stateSavedUpToDate()) // nothing happened since last project save return true; - AlignFrame[] frames = Desktop.getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); if (frames != null) { for (int i = 0; i < frames.length; i++) diff --git a/src/jalview/workers/AlignmentAnnotationFactory.java b/src/jalview/workers/AlignmentAnnotationFactory.java index c4e4b04..8b5240c 100644 --- a/src/jalview/workers/AlignmentAnnotationFactory.java +++ b/src/jalview/workers/AlignmentAnnotationFactory.java @@ -20,6 +20,8 @@ */ package jalview.workers; +import java.awt.Color; + import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.Jalview; @@ -27,8 +29,6 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; import jalview.gui.AlignFrame; -import java.awt.Color; - /** * Factory class with methods which allow clients (including external scripts * such as Groovy) to 'register and forget' an alignment annotation calculator. @@ -52,7 +52,7 @@ public class AlignmentAnnotationFactory */ public static void newCalculator(FeatureSetCounterI counter) { - AlignmentViewPanel currentAlignFrame = Jalview + AlignmentViewPanel currentAlignFrame = Jalview.getInstance() .getCurrentAlignFrame().alignPanel; if (currentAlignFrame == null) { @@ -74,7 +74,8 @@ public class AlignmentAnnotationFactory { // TODO need an interface for AlignFrame by which to access // its AlignViewportI and AlignmentViewPanel - AlignFrame currentAlignFrame = Jalview.getCurrentAlignFrame(); + AlignFrame currentAlignFrame = Jalview.getInstance() + .getCurrentAlignFrame(); if (currentAlignFrame != null) { new AnnotationWorker(currentAlignFrame.getViewport(), diff --git a/test/jalview/bin/CommandsTest.java b/test/jalview/bin/CommandsTest.java index ecec67d..de6185c 100644 --- a/test/jalview/bin/CommandsTest.java +++ b/test/jalview/bin/CommandsTest.java @@ -111,13 +111,13 @@ public class CommandsTest Assert.assertEquals(cmds.argsWereParsed(), cmdArgs, "Overall command parse and operation is false"); - Assert.assertEquals(Desktop.getAlignFrames().length, numFrames, + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, numFrames, "Wrong number of AlignFrames"); if (sequences != null) { Set openedSequenceNames = new HashSet<>(); - AlignFrame[] afs = Desktop.getAlignFrames(); + AlignFrame[] afs = Desktop.getDesktopAlignFrames(); for (AlignFrame af : afs) { openedSequenceNames.addAll( @@ -325,7 +325,7 @@ public class CommandsTest public static boolean lookForSequenceName(String sequenceName) { - AlignFrame[] afs = Desktop.getAlignFrames(); + AlignFrame[] afs = Desktop.getDesktopAlignFrames(); for (AlignFrame af : afs) { for (String name : af.getViewport().getAlignment().getSequenceNames()) diff --git a/test/jalview/bin/CommandsTest2.java b/test/jalview/bin/CommandsTest2.java index ae14c1a..a78ca5a 100644 --- a/test/jalview/bin/CommandsTest2.java +++ b/test/jalview/bin/CommandsTest2.java @@ -79,7 +79,7 @@ public class CommandsTest2 } ; - AlignFrame[] afs = Desktop.getAlignFrames(); + AlignFrame[] afs = Desktop.getDesktopAlignFrames(); Assert.assertNotNull(afs); Assert.assertTrue(afs.length > 0); diff --git a/test/jalview/gui/DesktopTests.java b/test/jalview/gui/DesktopTests.java index 5bf3507..f8fdb63 100644 --- a/test/jalview/gui/DesktopTests.java +++ b/test/jalview/gui/DesktopTests.java @@ -135,7 +135,7 @@ public class DesktopTests { Assert.fail("Unexpected exception " + x); } - AlignFrame[] alfs = Desktop.getAlignFrames(); + AlignFrame[] alfs = Desktop.getDesktopAlignFrames(); Assert.assertEquals("Expect just 2 alignment frames", 2, alfs.length); // internal paste should yield a new alignment window with shared dataset AlignmentI dataset = internalSource.getViewport().getAlignment() diff --git a/test/jalview/io/CrossRef2xmlTests.java b/test/jalview/io/CrossRef2xmlTests.java index c46477a..34cc17f 100644 --- a/test/jalview/io/CrossRef2xmlTests.java +++ b/test/jalview/io/CrossRef2xmlTests.java @@ -186,7 +186,7 @@ public class CrossRef2xmlTests extends Jalview2xmlBase SequenceFetcher sf = new SequenceFetcher(Desktop.instance, forSource, forAccession); sf.run(); - AlignFrame[] afs = Desktop.getAlignFrames(); + AlignFrame[] afs = Desktop.getDesktopAlignFrames(); if (afs.length == 0) { failedDBRetr.add("Didn't retrieve " + first); diff --git a/test/jalview/io/SequenceAnnotationReportTest.java b/test/jalview/io/SequenceAnnotationReportTest.java index bb5d1c4..9391eb1 100644 --- a/test/jalview/io/SequenceAnnotationReportTest.java +++ b/test/jalview/io/SequenceAnnotationReportTest.java @@ -432,8 +432,7 @@ public class SequenceAnnotationReportTest assertTrue(report.startsWith("\n" + "
    \n" + "UNIPROT P30410,\n" + " P30411,\n" + " P30412,\n" + " P30413,...
    \n" + "PDB0 3iu1
    \n" + "PDB1 3iu1
    ")); - assertTrue(report.endsWith("PDB5 3iu1
    \n" + "PDB6 3iu1
    \n" - + "PDB7 3iu1
    \n" + "PDB8,...
    \n" + assertTrue(report.endsWith("PDB3 3iu1
    \n"+"PDB4,...
    \n" + "(Output Sequence Details to list all database references)\n" + "
    ")); } diff --git a/test/jalview/io/cache/JvCacheableInputBoxTest.java b/test/jalview/io/cache/JvCacheableInputBoxTest.java index 5f9af25..ce34044 100644 --- a/test/jalview/io/cache/JvCacheableInputBoxTest.java +++ b/test/jalview/io/cache/JvCacheableInputBoxTest.java @@ -84,24 +84,28 @@ public class JvCacheableInputBoxTest cacheBox.addItem(testInput); cacheBox.setSelectedItem(testInput); cacheBox.updateCache(); - - try + boolean done[]=new boolean[] { false }; + // this event gets processed after updateCache's update event on the swing + // thread + SwingUtilities.invokeLater(() -> { + done[0]=true; + }); + long t=0; + while (!done[0] && t<200) { - // fix for JAL-4153 - // This delay is to let cacheBox.updateCache() finish updating the cache - SwingUtilities.invokeAndWait(() -> { - try - { - Thread.sleep(1); + try { + Thread.sleep(7); + t++; } catch (InterruptedException e) { e.printStackTrace(); } - }); - } catch (InvocationTargetException | InterruptedException e) + } + if (!done[0]) { - e.printStackTrace(); + Assert.fail("Giving up after 1.4s waiting for cache to be updated."); } + LinkedHashSet foundCache = appCache .getAllCachedItemsFor(TEST_CACHE_KEY); Assert.assertTrue(foundCache.contains(testInput)); diff --git a/test/jalview/project/Jalview2xmlTests.java b/test/jalview/project/Jalview2xmlTests.java index c9532cc..aa4be3d 100644 --- a/test/jalview/project/Jalview2xmlTests.java +++ b/test/jalview/project/Jalview2xmlTests.java @@ -287,12 +287,12 @@ public class Jalview2xmlTests extends Jalview2xmlBase @Test(groups = { "Functional" }) public void gatherViewsHere() throws Exception { - int origCount = Desktop.getAlignFrames() == null ? 0 - : Desktop.getAlignFrames().length; + int origCount = Desktop.getDesktopAlignFrames() == null ? 0 + : Desktop.getDesktopAlignFrames().length; AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/exampleFile_2_7.jar", DataSourceType.FILE); assertNotNull(af, "Didn't read in the example file correctly."); - assertTrue(Desktop.getAlignFrames().length == 1 + origCount, + assertTrue(Desktop.getDesktopAlignFrames().length == 1 + origCount, "Didn't gather the views in the example file."); } @@ -430,7 +430,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/exampleFile_2_7.jar", DataSourceType.FILE); - Assert.assertEquals(Desktop.getAlignFrames().length, 1); + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, 1); String afid = af.getViewport().getSequenceSetId(); // check FileLoader returned a reference to the one alignFrame that is @@ -440,8 +440,8 @@ public class Jalview2xmlTests extends Jalview2xmlBase Desktop.explodeViews(af); - int oldviews = Desktop.getAlignFrames().length; - Assert.assertEquals(Desktop.getAlignFrames().length, + int oldviews = Desktop.getDesktopAlignFrames().length; + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, Desktop.getAlignmentPanels(afid).length); File tfile = File.createTempFile("testStoreAndRecoverExpanded", ".jvp"); try @@ -455,14 +455,14 @@ public class Jalview2xmlTests extends Jalview2xmlBase Assert.fail("Didn't save the expanded view state", e); } Desktop.instance.closeAll_actionPerformed(null); - if (Desktop.getAlignFrames() != null) + if (Desktop.getDesktopAlignFrames() != null) { - Assert.assertEquals(Desktop.getAlignFrames().length, 0); + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, 0); } af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), DataSourceType.FILE); Assert.assertNotNull(af); - Assert.assertEquals(Desktop.getAlignFrames().length, + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, Desktop.getAlignmentPanels( af.getViewport().getSequenceSetId()).length); Assert.assertEquals(Desktop @@ -519,9 +519,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase Assert.fail("Didn't save the expanded view state", e); } Desktop.instance.closeAll_actionPerformed(null); - if (Desktop.getAlignFrames() != null) + if (Desktop.getDesktopAlignFrames() != null) { - Assert.assertEquals(Desktop.getAlignFrames().length, 0); + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, 0); } af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), @@ -698,9 +698,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase Assert.fail("Didn't save the expanded view state", e); } Desktop.instance.closeAll_actionPerformed(null); - if (Desktop.getAlignFrames() != null) + if (Desktop.getDesktopAlignFrames() != null) { - Assert.assertEquals(Desktop.getAlignFrames().length, 0); + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, 0); } af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(), @@ -792,9 +792,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase Assert.fail("Didn't save the state", e); } Desktop.instance.closeAll_actionPerformed(null); - if (Desktop.getAlignFrames() != null) + if (Desktop.getDesktopAlignFrames() != null) { - Assert.assertEquals(Desktop.getAlignFrames().length, 0); + Assert.assertEquals(Desktop.getDesktopAlignFrames().length, 0); } AlignFrame restoredFrame = new FileLoader().LoadFileWaitTillLoaded( @@ -1217,7 +1217,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase assertNotNull(af); AlignmentI ds = null; - for (AlignFrame alignFrame : Desktop.getAlignFrames()) + for (AlignFrame alignFrame : Desktop.getDesktopAlignFrames()) { if (ds == null) { diff --git a/test/jalview/renderer/seqfeatures/FeatureRendererTest.java b/test/jalview/renderer/seqfeatures/FeatureRendererTest.java index 53f98c3..0472317 100644 --- a/test/jalview/renderer/seqfeatures/FeatureRendererTest.java +++ b/test/jalview/renderer/seqfeatures/FeatureRendererTest.java @@ -638,7 +638,7 @@ public class FeatureRendererTest /* * find the complement frames (ugly) */ - AlignFrame[] frames = Desktop.getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); assertEquals(frames.length, 2); AlignViewport av1 = frames[0].getViewport(); AlignViewport av2 = frames[1].getViewport();