From 8dadf27423ca69874dc6a3c9d416974ba5ae767f Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 5 Feb 2021 17:03:12 +0000 Subject: [PATCH] =?utf8?q?JAL-3811=20document=20SHOW=5FJWS2=5FSERVICES=20use?= =?utf8?q?r=20preference=20and=20provide=20new=20menu=20option=20for=20=E2=80?= =?utf8?q?=98one=20off=E2=80=99=20JABAWS=20discovery=20if=20preference=20is=20?= =?utf8?q?disabled.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/bin/Cache.java | 2 ++ src/jalview/gui/AlignFrame.java | 32 +++++++++++++++++++++++++++++--- src/jalview/gui/Desktop.java | 26 +++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 2904fc3..3669117 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -167,6 +167,8 @@ import jalview.ws.sifts.SiftsSettings; *
  • FOLLOW_SELECTIONS (true) Controls whether a new alignment view should * respond to selections made in other alignments containing the same sequences. *
  • + *
  • SHOW_JWS2_SERVICES (true) when set to false, jalview will not + * auto-discover JABAWS services
  • *
  • JWS2HOSTURLS comma-separated list of URLs to try for JABAWS services
  • *
  • SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery * warning dialog box is displayed.
  • diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index b1efed6..9013416 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4174,9 +4174,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, webService.add(me.webServiceNoServices); } // TODO: move into separate menu builder class. - boolean new_sspred = false; - if (Cache.getDefault("SHOW_JWS2_SERVICES", true)) { + // logic for 2.11.1.4 is + // always look to see if there is a discover. if there isn't + // we can't show any Jws2 services + // if there are services available, show them - regardless of + // the 'show JWS2 preference' + // if the discoverer is running then say so + // otherwise offer to trigger discovery if 'show JWS2' is not + // enabled Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer(); if (jws2servs != null) { @@ -4193,8 +4199,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } } - } + if (jws2servs.isRunning()) { JMenuItem tm = new JMenuItem( @@ -4202,6 +4208,26 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, tm.setEnabled(false); webService.add(tm); } + else if (!Cache.getDefault("SHOW_JWS2_SERVICES", true)) + { + JMenuItem enableJws2 = new JMenuItem( + "Discover Web Services"); + enableJws2.setToolTipText( + "Select to start JABA Web Service discovery (or enable option in Web Service preferences)"); + enableJws2.setEnabled(true); + enableJws2.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + // start service discoverer, but ignore preference + Desktop.instance.startServiceDiscovery(false, + true); + } + }); + webService.add(enableJws2); + } } } build_urlServiceMenu(me.webService); diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 0441e5e..f06adc4 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -2571,13 +2571,36 @@ public class Desktop extends jalview.jbgui.GDesktop this.inBatchMode = inBatchMode; } + /** + * start service discovery and wait till it is done + */ public void startServiceDiscovery() { startServiceDiscovery(false); } + /** + * start service discovery threads - blocking or non-blocking + * + * @param blocking + */ public void startServiceDiscovery(boolean blocking) { + startServiceDiscovery(blocking,false); + } + + /** + * start service discovery threads + * + * @param blocking + * - false means call returns immediately + * @param ignore_SHOW_JWS2_SERVICES_preference + * - when true JABA services are discovered regardless of user's JWS2 + * discovery preference setting + */ + public void startServiceDiscovery(boolean blocking, + boolean ignore_SHOW_JWS2_SERVICES_preference) + { boolean alive = true; Thread t0 = null, t1 = null, t2 = null; // JAL-940 - JALVIEW 1 services are now being EOLed as of JABA 2.1 release @@ -2595,7 +2618,8 @@ public class Desktop extends jalview.jbgui.GDesktop (t0 = new Thread(discoverer)).start(); } - if (Cache.getDefault("SHOW_JWS2_SERVICES", true)) + if (ignore_SHOW_JWS2_SERVICES_preference + || Cache.getDefault("SHOW_JWS2_SERVICES", true)) { t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer() .startDiscoverer(changeSupport); -- 1.7.10.2