ensure presets and parameters are discovered when service is discovered
[jalview.git] / src / jalview / ws / jws2 / Jws2Discoverer.java
index 2ef9cfd..fdbb740 100644 (file)
@@ -162,7 +162,12 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     }
     System.out.println("Discovered service: " + jwsservers + " "
             + srv.toString());
-    services.add(new Jws2Instance(jwsservers, srv.toString(), service2));
+    Jws2Instance service = new Jws2Instance(jwsservers, srv.toString(), service2);
+
+    services.add(service); 
+    // retrieve the presets and parameter set and cache now
+    service.getParamStore().getPresets();
+    service.hasParameters();
   }
 
   public class Jws2Instance
@@ -277,7 +282,24 @@ 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;
     }
   };
 
@@ -317,7 +339,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
@@ -344,6 +366,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
 
     });
     wsmenu.add(jws2al);
+    
   }
 
   private void populateWSMenuEntry(JMenu jws2al, final AlignFrame alignFrame)
@@ -362,6 +385,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;
@@ -383,16 +407,22 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
           atpoint.setToolTipText(service.getActionText());
         }
       }
-      if (!byhost && !hostLabels.contains(host + service.getActionText()))
+      if (!byhost && !hostLabels.contains(host + service.serviceType+service.getActionText()))
+              //!hostLabels.contains(host + (bytype ? service.serviceType+service.getActionText() : "")))
       {
         // add a marker indicating where this service is hosted
         // relies on services from the same host being listed in a contiguous
         // 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);
+          lasthost = host;
+        }
+        hostLabels.addElement(host + service.serviceType+service.getActionText() );
+        // hostLabels.addElement(host + (bytype ? service.serviceType+service.getActionText() : ""));
       }
       msacl.attachWSMenuEntry(atpoint, service, alignFrame);
       /*