+
+ public void startServiceDiscovery(boolean blocking)
+ {
+ boolean alive = true;
+ Thread t0 = null, t1 = null, t2 = null;
+
+ // todo: changesupport handlers need to be transferred
+ if (discoverer == null)
+ {
+ discoverer = new jalview.ws.jws1.Discoverer();
+ // register PCS handler for desktop.
+ discoverer.addPropertyChangeListener(changeSupport);
+ }
+ // JAL-940 - disabled JWS1 service configuration - always start discoverer until we phase out completely
+ if (true)
+ {
+ (t0 = new Thread(discoverer)).start();
+ }
+
+ try
+ {
+ if (Cache.getDefault("SHOW_ENFIN_SERVICES", true))
+ {
+ // EnfinEnvision web service menu entries are rebuild every time the
+ // menu is shown, so no changeSupport events are needed.
+ jalview.ws.EnfinEnvision2OneWay.getInstance();
+ (t1 = new Thread(jalview.ws.EnfinEnvision2OneWay.getInstance()))
+ .start();
+ }
+ } catch (Exception e)
+ {
+ Cache.log
+ .info("Exception when trying to launch Envision2 workflow discovery.",
+ e);
+ Cache.log.info(e.getStackTrace());
+ }
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning())
+ {
+ jalview.ws.jws2.Jws2Discoverer.getDiscoverer().setAborted(true);
+ }
+ t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(
+ changeSupport);
+
+ }
+ Thread t3=null;
+ {
+ // TODO: do rest service discovery
+ }
+ if (blocking)
+ {
+ while (alive)
+ {
+ try
+ {
+ Thread.sleep(15);
+ } catch (Exception e)
+ {
+ }
+ alive = (t1 != null && t1.isAlive())
+ || (t2 != null && t2.isAlive())
+ || (t3 != null && t3.isAlive())
+ || (t0 != null && t0.isAlive());
+ }
+ }
+ }
+
+ /**
+ * called to check if the service discovery process completed successfully.
+ *
+ * @param evt
+ */
+ protected void JalviewServicesChanged(PropertyChangeEvent evt)
+ {
+ if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
+ {
+ final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ .getErrorMessages();
+ if (ermsg != null)
+ {
+ if (Cache.getDefault("SHOW_WSDISCOVERY_ERRORS", true))
+ {
+ if (serviceChangedDialog == null)
+ {
+ // only run if we aren't already displaying one of these.
+ javax.swing.SwingUtilities
+ .invokeLater(serviceChangedDialog = new Runnable()
+ {
+ public void run()
+ {
+
+ JOptionPane
+ .showInternalMessageDialog(
+ Desktop.desktop,
+ ermsg
+ + "It may be that you have invalid JABA URLs\nin your web service preferences.\n\nGo to the Web services tab of the\nTools->Preferences dialog box to change them.\n",
+ "Preferences Problem",
+ JOptionPane.WARNING_MESSAGE);
+ serviceChangedDialog = null;
+
+ }
+ });
+ }
+ }
+ else
+ {
+ Cache.log
+ .error("Errors reported by JABA discovery service. Check web services preferences.\n"
+ + ermsg);
+ }
+ }
+ }
+ }
+
+ private Runnable serviceChangedDialog = null;
+
+ /**
+ * start a thread to open a URL in the configured browser. Pops up a warning
+ * dialog to the user if there is an exception when calling out to the browser
+ * to open the URL.
+ *
+ * @param url
+ */
+ public static void showUrl(final String url)
+ {
+ showUrl(url, Desktop.instance);
+ }
+ /**
+ * Like showUrl but allows progress handler to be specified
+ * @param url
+ * @param progress (null) or object implementing IProgressIndicator
+ */
+ public static void showUrl(final String url, final IProgressIndicator progress)
+ {
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ if (progress!=null) {
+ progress.setProgressBar("Opening "+url, this.hashCode());
+ }
+ jalview.util.BrowserLauncher.openURL(url);
+ } catch (Exception ex)
+ {
+ JOptionPane
+ .showInternalMessageDialog(
+ Desktop.desktop,
+ "Unixers: Couldn't find default web browser."
+ + "\nAdd the full path to your browser in Preferences.",
+ "Web browser not found",
+ JOptionPane.WARNING_MESSAGE);
+
+ ex.printStackTrace();
+ }
+ if (progress!=null) {
+ progress.setProgressBar(null, this.hashCode());
+ }
+ }
+ }).start();
+ }
+
+ public static WsParamSetManager wsparamManager = null;
+
+ public static ParamManager getUserParameterStore()
+ {
+ if (wsparamManager == null)
+ {
+ wsparamManager = new WsParamSetManager();
+ }
+ return wsparamManager;
+ }
+
+