JAL-1379 graceful degradation to legacy service when JABAWS Jpred service not available
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Sat, 5 Oct 2013 13:01:00 +0000 (14:01 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Sat, 5 Oct 2013 13:01:00 +0000 (14:01 +0100)
src/jalview/gui/AlignFrame.java

index ceb08ee..829b9ab 100755 (executable)
@@ -77,6 +77,7 @@ import jalview.schemes.UserColourScheme;
 import jalview.schemes.ZappoColourScheme;
 import jalview.ws.jws1.Discoverer;
 import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.awt.BorderLayout;
@@ -4158,6 +4159,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       @Override
       public void run()
       {
+        final List<JMenuItem> legacyItems=new ArrayList<JMenuItem>();
         try
         {
           System.err.println("Building ws menu again "
@@ -4189,28 +4191,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             // TODO: refactor to allow list of AbstractName/Handler bindings to
             // be
             // stored or retrieved from elsewhere
-            Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
+            // No MSAWS used any more:
+            // Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
             Vector secstrpr = (Vector) Discoverer.services
                     .get("SecStrPred");
-            Vector seqsrch = null; // (Vector)
-                                   // Discoverer.services.get("SeqSearch");
-            // TODO: move GUI generation code onto service implementation - so a
-            // client instance attaches itself to the GUI with method call like
-            // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
-            // alignframe)
-            if (msaws != null)
-            {
-              // Add any Multiple Sequence Alignment Services
-              for (int i = 0, j = msaws.size(); i < j; i++)
-              {
-                final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
-                        .get(i);
-                jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
-                        .getServiceClient(sh);
-                impl.attachWSMenuEntry(msawsmenu, me);
-
-              }
-            }
             if (secstrpr != null)
             {
               // Add any secondary structure prediction services
@@ -4220,35 +4204,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                         .get(i);
                 jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
                         .getServiceClient(sh);
+                int p=secstrmenu.getItemCount();
                 impl.attachWSMenuEntry(secstrmenu, me);
-              }
-            }
-            if (seqsrch != null)
-            {
-              // Add any sequence search services
-              for (int i = 0, j = seqsrch.size(); i < j; i++)
-              {
-                final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
-                        .elementAt(i);
-                jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
-                        .getServiceClient(sh);
-                impl.attachWSMenuEntry(seqsrchmenu, me);
+                int q=secstrmenu.getItemCount();
+                for (int litm=p;litm<q; litm++)
+                {
+                  legacyItems.add(secstrmenu.getItem(litm));
+                }
               }
             }
           }
-
+          
           // Add all submenus in the order they should appear on the web
           // services menu
           wsmenu.add(msawsmenu);
           wsmenu.add(secstrmenu);
           wsmenu.add(dismenu);
           wsmenu.add(analymenu);
-          // final ArrayList<JMenu> submens=new ArrayList<JMenu>();
-          // submens.add(msawsmenu);
-          // submens.add(secstrmenu);
-          // submens.add(dismenu);
-          // submens.add(analymenu);
-
           // No search services yet
           // wsmenu.add(seqsrchmenu);
 
@@ -4273,6 +4245,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                   webService.add(me.webServiceNoServices);
                 }
                 // TODO: move into separate menu builder class.
+                boolean new_sspred=false;
                 if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
                 {
                   Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
@@ -4281,6 +4254,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                     if (jws2servs.hasServices())
                     {
                       jws2servs.attachWSMenuEntry(webService, me);
+                      for (Jws2Instance sv:jws2servs.getServices()) {
+                        if (sv.description.toLowerCase().contains("jpred"))
+                        {
+                          for (JMenuItem jmi:legacyItems)
+                          {
+                            jmi.setVisible(false);
+                          }
+                        }
+                      }
+                      
                     }
                     if (jws2servs.isRunning())
                     {
@@ -4291,7 +4274,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                     }
                   }
                 }
-
                 build_urlServiceMenu(me.webService);
                 build_fetchdbmenu(webService);
                 for (JMenu item : wsmenu)