import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.*;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Cache.log.debug("Filechooser init thread finished.");
}
}).start();
+ // Add the service change listener
+ changeSupport.addJalviewPropertyChangeListener("services",
+ new PropertyChangeListener()
+ {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ Cache.log.debug("Firing service changed event for "
+ + evt.getNewValue());
+ JalviewServicesChanged(evt);
+ }
+
+ });
}
/**
}
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning()) {
+ if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning())
+ {
jalview.ws.jws2.Jws2Discoverer.getDiscoverer().setAborted(true);
}
- t2=jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(changeSupport);
-
+ t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer().startDiscoverer(
+ changeSupport);
+
}
if (blocking)
{
}
/**
+ * called to check if the service discovery process completed successfully.
+ *
+ * @param evt
+ */
+ protected void JalviewServicesChanged(PropertyChangeEvent evt)
+ {
+ if (evt.getNewValue() instanceof Vector)
+ {
+ final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ .getErrorMessages();
+ if (ermsg != null)
+ {
+ 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
+ + "\nPlease check the web services preferences.\n",
+ "Preferences Problem",
+ JOptionPane.WARNING_MESSAGE);
+ serviceChangedDialog = null;
+
+ }
+ });
+ }
+ }
+ }
+ }
+
+ 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.
{
if (Jws2Client.validURL(jwsservers))
{
+ boolean noservices=true;
// look for services
for (Services srv : Services.values())
{
{
e.printStackTrace();
}
+ // For moment, report service as a problem.
+ jws2Discoverer.addInvalidServiceUrl(jwsservers);
}
;
if (service != null)
{
+ noservices=false;
jws2Discoverer.addService(jwsservers, srv, service);
}
}
-
+ if (noservices)
+ {
+ jws2Discoverer.addUrlwithnoservices(jwsservers);
+ }
}
else
{
+ jws2Discoverer.addInvalidServiceUrl(jwsservers);
Cache.log.info("Ignoring invalid Jws2 service url " + jwsservers);
}
} catch (Exception e)
{
e.printStackTrace();
Cache.log.warn("Exception when discovering Jws2 services.", e);
+ jws2Discoverer.addInvalidServiceUrl(jwsservers);
} catch (Error e)
{
Cache.log.error("Exception when discovering Jws2 services.", e);
+ jws2Discoverer.addInvalidServiceUrl(jwsservers);
}
running=false;
}
boolean running = false, aborted = false;
/**
+ * @return the aborted
+ */
+ public boolean isAborted()
+ {
+ return aborted;
+ }
+
+ /**
* @param aborted
* the aborted to set
*/
} catch (ClassNotFoundException e)
{
System.err
- .println("Not enabling Jalview Webservices version 2: client jar is not available."
+ .println("Not enabling JABA Webservices : client jar is not available."
+ "\nPlease check that your webstart JNLP file is up to date!");
running = false;
return;
}
+ // reinitialise records of good and bad service URLs
if (services != null)
{
services.removeAllElements();
}
+ if (urlsWithoutServices != null)
+ {
+ urlsWithoutServices.removeAllElements();
+ }
+ if (invalidServiceUrls != null)
+ {
+ invalidServiceUrls.removeAllElements();
+ }
+
List<JabaWsServerQuery> qrys = new ArrayList<JabaWsServerQuery>();
for (final String jwsservers : getServiceUrls())
{
public static void main(String[] args)
{
- Thread runner = getDiscoverer().startDiscoverer(new PropertyChangeListener()
- {
-
- public void propertyChange(PropertyChangeEvent evt)
- {
- if (getDiscoverer().services!=null)
- {System.out.println("Changesupport: There are now "
- + getDiscoverer().services.size() + " services");
-
- }
- }
- });
+ Thread runner = getDiscoverer().startDiscoverer(
+ new PropertyChangeListener()
+ {
+
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if (getDiscoverer().services != null)
+ {
+ System.out.println("Changesupport: There are now "
+ + getDiscoverer().services.size() + " services");
+
+ }
+ }
+ });
while (runner.isAlive())
{
try
{ "-h=" + foo.toString() });
} catch (Exception e)
{
+ e.printStackTrace();
return false;
} catch (OutOfMemoryError e)
{
+ e.printStackTrace();
return false;
} catch (Error e)
{
+ e.printStackTrace();
return false;
}
+
return true;
}
/**
- * Start a fresh discovery thread and notify the given object when we're finished. Any known existing threads will be killed before this one is started.
+ * Start a fresh discovery thread and notify the given object when we're
+ * finished. Any known existing threads will be killed before this one is
+ * started.
+ *
* @param changeSupport2
* @return new thread
*/
return thr;
}
+ Vector<String> invalidServiceUrls = null, urlsWithoutServices = null;
+
+ /**
+ * @return the invalidServiceUrls
+ */
+ public Vector<String> getInvalidServiceUrls()
+ {
+ return invalidServiceUrls;
+ }
+
+ /**
+ * @return the urlsWithoutServices
+ */
+ public Vector<String> getUrlsWithoutServices()
+ {
+ return urlsWithoutServices;
+ }
+
+ /**
+ * add an 'empty' JABA server to the list
+ *
+ * @param jwsservers
+ */
+ public synchronized void addUrlwithnoservices(String jwsservers)
+ {
+ if (urlsWithoutServices == null)
+ {
+ urlsWithoutServices = new Vector<String>();
+ }
+ if (!urlsWithoutServices.contains(jwsservers))
+ {
+ urlsWithoutServices.add(jwsservers);
+ }
+ }
+
+ /**
+ * add a bad URL to the list
+ *
+ * @param jwsservers
+ */
+ public synchronized void addInvalidServiceUrl(String jwsservers)
+ {
+ if (invalidServiceUrls == null)
+ {
+ invalidServiceUrls = new Vector<String>();
+ }
+ if (!invalidServiceUrls.contains(jwsservers))
+ {
+ invalidServiceUrls.add(jwsservers);
+ }
+ }
+
+ /**
+ *
+ * @return a human readable report of any problems with the service URLs used
+ * for discovery
+ */
+ public String getErrorMessages()
+ {
+ if (!isRunning() && !isAborted())
+ {
+ StringBuffer ermsg = new StringBuffer();
+ boolean list = false;
+ if (getInvalidServiceUrls() != null
+ && getInvalidServiceUrls().size() > 0)
+ {
+ ermsg.append("Invalid Service URLS: \n");
+ for (String svcurl : getInvalidServiceUrls())
+ {
+ if (list)
+ {
+ ermsg.append(", ");
+ }
+ list = true;
+ ermsg.append(svcurl);
+ }
+ ermsg.append("\n\n");
+ }
+ list = false;
+ if (getUrlsWithoutServices() != null
+ && getUrlsWithoutServices().size() > 0)
+ {
+ ermsg.append("URLs without any JABA Services : \n");
+ for (String svcurl : getUrlsWithoutServices())
+ {
+ if (list)
+ {
+ ermsg.append(", ");
+ }
+ list = true;
+ ermsg.append(svcurl);
+ }
+ ermsg.append("\n");
+ }
+ if (ermsg.length() > 1)
+ {
+ return ermsg.toString();
+ }
+
+ }
+ return null;
+ }
+
}