Jalview 2.6 source licence
[jalview.git] / src / jalview / ws / jws2 / Jws2Discoverer.java
index ceff8e4..8e29817 100644 (file)
@@ -1,3 +1,20 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * 
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package jalview.ws.jws2;
 
 import java.awt.Color;
@@ -164,8 +181,10 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
             + srv.toString());
     Jws2Instance service = new Jws2Instance(jwsservers, srv.toString(), service2);
 
-    services.add(service);
-    service.getParamStore();
+    services.add(service); 
+    // retrieve the presets and parameter set and cache now
+    service.getParamStore().getPresets();
+    service.hasParameters();
   }
 
   public class Jws2Instance
@@ -280,7 +299,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;
     }
   };
 
@@ -320,7 +356,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
@@ -388,7 +424,8 @@ 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
@@ -399,8 +436,10 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
         {
           atpoint.add(hitm = new JMenuItem(host));
           hitm.setForeground(Color.blue);
+          lasthost = host;
         }
-        hostLabels.addElement(lasthost=host);
+        hostLabels.addElement(host + service.serviceType+service.getActionText() );
+        // hostLabels.addElement(host + (bytype ? service.serviceType+service.getActionText() : ""));
       }
       msacl.attachWSMenuEntry(atpoint, service, alignFrame);
       /*