From: jprocter Date: Thu, 15 Sep 2011 13:14:38 +0000 (+0100) Subject: JAL-854 tweaked menu layout so services appear before the fetch DB refs submenu X-Git-Tag: Release_2_7~43 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cb4b4b590add93fb0fb5c5ecd1d0532f1456ecc2;p=jalview.git JAL-854 tweaked menu layout so services appear before the fetch DB refs submenu --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index ba112b8..b9ba4e0 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -3967,7 +3967,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, final JMenu seqsrchmenu = new JMenu( "Sequence Database Search"); final JMenu analymenu = new JMenu( - "Analyse Alignment"); + "Analysis"); if (Cache.getDefault("SHOW_JWS1_SERVICES", true) && Discoverer.services != null @@ -4031,23 +4031,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { if (jws2servs.hasServices()) { - JMenu jws2men = new JMenu("Jaba Web Services"); jws2servs.attachWSMenuEntry(msawsmenu, me); -// for (int i = 0, iSize = jws2men.getMenuComponentCount(); i < iSize; i++) -// { -// msawsmenu.add(jws2men.getMenuComponent(i)); -// } } } } - if (msawsmenu.getMenuComponentCount()>0) - wsmenu.add(msawsmenu); - if (secstrmenu.getMenuComponentCount()>0) - wsmenu.add(secstrmenu); - if (analymenu.getMenuComponentCount()>0) - wsmenu.add(analymenu); - if (seqsrchmenu.getMenuComponentCount()>0) - wsmenu.add(seqsrchmenu); + // Add all submenus in the order they should appear on the web services menu + wsmenu.add(msawsmenu); + wsmenu.add(secstrmenu); + wsmenu.add(analymenu); + // No search services yet + // wsmenu.add(seqsrchmenu); javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -4055,9 +4048,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { try { - - resetWebServiceMenu(); - // finally, add the whole shebang onto the webservices menu + webService.removeAll(); + // first, add discovered services onto the webservices menu if (wsmenu.size() > 0) { for (int i = 0, j = wsmenu.size(); i < j; i++) @@ -4067,8 +4059,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } else { - me.webService.add(me.webServiceNoServices); + webService.add(me.webServiceNoServices); } + build_urlServiceMenu(me.webService); + build_fetchdbmenu(webService); } catch (Exception e) { } @@ -4086,17 +4080,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } - /** - * empty the web service menu and add any ad-hoc functions not dynamically - * discovered. - * - */ - private void resetWebServiceMenu() - { - webService.removeAll(); - build_fetchdbmenu(webService); - build_urlServiceMenu(webService); - } /** * construct any groupURL type service menu entries. @@ -4105,11 +4088,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ private void build_urlServiceMenu(JMenu webService) { - if (Cache.getDefault("SHOW_ENFIN_SERVICES", true)) - { - jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry( - webService, this); - } // TODO: remove this code when 2.7 is released // DEBUG - alignmentView /* @@ -4125,11 +4103,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // TODO: refactor to RestClient discoverer and merge menu entries for // rest-style services with other types of analysis/calculation service // SHmmr test client - still being implemented. + // DEBUG - alignmentView for (jalview.ws.rest.RestClient client: jalview.ws.rest.RestClient.getRestClients()) { client.attachWSMenuEntry(JvSwingUtils.findOrCreateMenu(webService, client.getAction()), this); } - // DEBUG - alignmentView + + if (Cache.getDefault("SHOW_ENFIN_SERVICES", true)) + { + jalview.ws.EnfinEnvision2OneWay.getInstance().attachWSMenuEntry( + webService, this); + } } /* diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index 2650eae..b921a81 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -26,6 +26,7 @@ import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JMenu; +import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.SwingConstants; @@ -171,4 +172,23 @@ public final class JvSwingUtils return getLabelFont(false,false); } + /** + * clean up a swing menu. + * Removes any empty submenus without selection listeners. + * @param webService + */ + public static void cleanMenu(JMenu webService) + { + for (int i=0;i