JAL-1137 clean up old-style menu code and look
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 7 Aug 2012 15:56:40 +0000 (16:56 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 7 Aug 2012 15:56:40 +0000 (16:56 +0100)
src/jalview/ws/jws2/Jws2Discoverer.java

index a727485..c0addfe 100644 (file)
@@ -395,16 +395,16 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
    */
   private void addEnumeratedServices(final JMenu jws2al, final AlignFrame alignFrame, List<Jws2Instance> enumerableServices)
   {
-      boolean byhost = Cache.getDefault("WSMENU_BYHOST", false), bytype = Cache
-              .getDefault("WSMENU_BYTYPE", false);
-      /**
-       * eventually, JWS2 services will appear under the same align/etc submenus.
-       * for moment we keep them separate.
-       */
-      JMenu atpoint;
-      MsaWSClient msacl = new MsaWSClient();
-      Vector hostLabels = new Vector();
-        Hashtable<String,String> lasthostFor = new Hashtable<String,String>();
+    boolean byhost = Cache.getDefault("WSMENU_BYHOST", false), bytype = Cache
+            .getDefault("WSMENU_BYTYPE", false);
+    /**
+     * eventually, JWS2 services will appear under the same align/etc submenus.
+     * for moment we keep them separate.
+     */
+    JMenu atpoint;
+    MsaWSClient msacl = new MsaWSClient();
+    List<String> hostLabels = new ArrayList<String>();
+    Hashtable<String, String> lasthostFor = new Hashtable<String, String>();
     Hashtable<String, ArrayList<Jws2Instance>> hosts = new Hashtable<String, ArrayList<Jws2Instance>>();
     ArrayList<String> hostlist=new ArrayList<String>();
     for (Jws2Instance service : enumerableServices)
@@ -460,7 +460,11 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
           // contiguous
           // group
           JMenuItem hitm;
-          atpoint.addSeparator();
+          if (hostLabels.contains(host)) {
+            atpoint.addSeparator();
+          } else {
+            hostLabels.add(host);
+          }
           if (lasthostFor.get(service.action) == null || !lasthostFor.get(service.action).equals(host))
           {
             atpoint.add(hitm = new JMenuItem(host));
@@ -478,25 +482,11 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
                     .wrapTooltip("Opens the JABAWS server's homepage in web browser"));
             lasthostFor.put(service.action,host);
           }
-          hostLabels.addElement(host + service.serviceType
+          hostLabels.add(host + service.serviceType
                   + service.getActionText());
-          // hostLabels.addElement(host + (bytype ?
-          // service.serviceType+service.getActionText() : ""));
         }
         
         service.attachWSMenuEntry(atpoint, alignFrame);
-        /*
-         * JMenuItem sitem = new JMenuItem(service.serviceType);
-         * sitem.setToolTipText("Hosted at " + service.hosturl);
-         * sitem.addActionListener(new ActionListener() {
-         * 
-         * @Override public void actionPerformed(ActionEvent e) { AlignmentView
-         * msa = alignFrame.gatherSequencesForAlignment(); MsaWSClient client =
-         * new MsaWSClient(service, "JWS2 Alignment of " +
-         * alignFrame.getTitle(), msa, false, true,
-         * alignFrame.getViewport().getAlignment().getDataset(), alignFrame); }
-         * });
-         */
       }
     }
   }