cache the runner config so the preset list can be retrieved quickly
[jalview.git] / src / jalview / ws / jws2 / Jws2Discoverer.java
index dda8c4e..d6e4d78 100644 (file)
@@ -280,7 +280,23 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     public String getUri()
     {
       // this is only valid for Jaba 1.0 - this formula might have to change!
-      return hosturl+"/"+serviceType;
+      return hosturl+(hosturl.lastIndexOf("/")==(hosturl.length()-1) ? "/" : "") +serviceType;
+    }
+    private boolean hasParams=false,lookedForParams=false;
+    public boolean hasParameters()
+    {
+      if (!lookedForParams)
+      {
+        lookedForParams=true;
+      try
+      {
+        hasParams = (getRunnerConfig().getArguments().size() > 0);
+      } catch (Exception e)
+      {
+
+      }
+      }
+      return hasParams;
     }
   };
 
@@ -320,7 +336,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
   public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
   {
     // dynamically regenerate service list.
-    final JMenu jws2al = new JMenu("JABA Alignment");
+    final JMenu jws2al = new JMenu("JABAWS Alignment");
     jws2al.addMenuListener(new MenuListener()
     {
       // TODO: future: add menu listener to parent menu - so submenus are
@@ -366,6 +382,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     MsaWSClient msacl = new MsaWSClient();
     Vector hostLabels = new Vector();
     jws2al.removeAll();
+    String lasthost=null;
     for (final Jws2Instance service : services)
     {
       atpoint = jws2al;
@@ -394,9 +411,12 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
         // group
         JMenuItem hitm;
         atpoint.addSeparator();
-        atpoint.add(hitm = new JMenuItem(host));
-        hitm.setForeground(Color.blue);
-        hostLabels.addElement(host);
+        if (lasthost==null || !lasthost.equals(host))
+        {
+          atpoint.add(hitm = new JMenuItem(host));
+          hitm.setForeground(Color.blue);
+        }
+        hostLabels.addElement(lasthost=host);
       }
       msacl.attachWSMenuEntry(atpoint, service, alignFrame);
       /*