From cb0510ac1a059636122bd8ee0b6ad0bfbdcaa2a6 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sat, 5 Oct 2013 12:13:12 +0100 Subject: [PATCH] JAL-1379 JAL-1358 only enable/disable menu entries associated with services not applicable for the current sequence type --- .../ws/jws2/SequenceAnnotationWSClient.java | 80 +++++++++++--------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java index cca6af3..59cc962 100644 --- a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java +++ b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java @@ -301,42 +301,7 @@ public class SequenceAnnotationWSClient extends Jws2Client { final JCheckBoxMenuItem aaConEnabled = new JCheckBoxMenuItem( aaui.getAAconToggle()); - wsmenu.addMenuListener(new MenuListener() - { - @Override - public void menuSelected(MenuEvent arg0) - { - // TODO: refactor to the implementing class. - wsmenu.setEnabled((alignFrame.getViewport().getAlignment() - .isNucleotide() ? aaui.isNa() : aaui.isPr())); - List aaconClient = alignFrame.getViewport() - .getCalcManager() - .getRegisteredWorkersOfClass(aaui.getClient()); - if (aaconClient != null && aaconClient.size() > 0) - { - aaConEnabled.setSelected(true); - } - else - { - aaConEnabled.setSelected(false); - } - } - - @Override - public void menuDeselected(MenuEvent arg0) - { - // TODO Auto-generated method stub - - } - - @Override - public void menuCanceled(MenuEvent arg0) - { - // TODO Auto-generated method stub - - } - }); aaConEnabled.setToolTipText("

" + JvSwingUtils.wrapTooltip(aaui.getAAconToggleTooltip() + "

") + ""); @@ -361,7 +326,7 @@ public class SequenceAnnotationWSClient extends Jws2Client }); wsmenu.add(aaConEnabled); - JMenuItem modifyParams = new JMenuItem(aaui.getAAeditSettings()); + final JMenuItem modifyParams = new JMenuItem(aaui.getAAeditSettings()); modifyParams.setToolTipText("

" + JvSwingUtils.wrapTooltip(aaui.getAAeditSettingsTooltip() + "

") + ""); @@ -375,6 +340,49 @@ public class SequenceAnnotationWSClient extends Jws2Client } }); wsmenu.add(modifyParams); + wsmenu.addMenuListener(new MenuListener() + { + + @Override + public void menuSelected(MenuEvent arg0) + { + // TODO: refactor to the implementing class. + if (alignFrame.getViewport().getAlignment() + .isNucleotide() ? aaui.isNa() : aaui.isPr()) { + aaConEnabled.setEnabled(true); + modifyParams.setEnabled(true); + } + else { + aaConEnabled.setEnabled(false); + modifyParams.setEnabled(false); + } + List aaconClient = alignFrame.getViewport() + .getCalcManager() + .getRegisteredWorkersOfClass(aaui.getClient()); + if (aaconClient != null && aaconClient.size() > 0) + { + aaConEnabled.setSelected(true); + } + else + { + aaConEnabled.setSelected(false); + } + } + + @Override + public void menuDeselected(MenuEvent arg0) + { + // TODO Auto-generated method stub + + } + + @Override + public void menuCanceled(MenuEvent arg0) + { + // TODO Auto-generated method stub + + } + }); } return true; -- 1.7.10.2