ensure service menu is rebuilt after update listeners registered, and flatten JWS2...
authorjprocter <Jim Procter>
Mon, 21 Jun 2010 10:15:25 +0000 (10:15 +0000)
committerjprocter <Jim Procter>
Mon, 21 Jun 2010 10:15:25 +0000 (10:15 +0000)
src/jalview/gui/AlignFrame.java

index 6ee243e..ca4a48b 100755 (executable)
@@ -516,10 +516,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   private void addServiceListeners()
   {
     final java.beans.PropertyChangeListener thisListener;
-    // Do this once to get current state
-    BuildWebServiceMenu();
     Desktop.instance.addJalviewPropertyChangeListener("services",
-            thisListener=new java.beans.PropertyChangeListener()
+            thisListener = new java.beans.PropertyChangeListener()
             {
               public void propertyChange(PropertyChangeEvent evt)
               {
@@ -547,10 +545,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               javax.swing.event.InternalFrameEvent evt)
       {
         System.out.println("deregistering discoverer listener");
-        Desktop.instance.removeJalviewPropertyChangeListener("services",thisListener);
+        Desktop.instance.removeJalviewPropertyChangeListener("services",
+                thisListener);
         closeMenuItem_actionPerformed(true);
       };
     });
+    // Finally, build the menu once to get current service state
+    BuildWebServiceMenu();
   }
 
   public void setGUINucleotide(boolean nucleotide)
@@ -3900,7 +3901,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           {
             JMenu jws2men = new JMenu("Jalview 2 Services");
             jws2servs.attachWSMenuEntry(jws2men, this);
-            wsmenu.add(jws2men);
+            for (int i = 0, iSize = jws2men.getMenuComponentCount(); i < iSize; i++)
+            {
+              wsmenu.add(jws2men.getMenuComponent(i));
+            }
           }
         }
       }