From: Mateusz Warowny Date: Mon, 17 Jul 2023 10:46:37 +0000 (+0200) Subject: JAL-4232 Disable menu items for RNA services for proteins. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fpatch%2FJAL-4232-disable-unavailable-services;p=jalview.git JAL-4232 Disable menu items for RNA services for proteins. --- diff --git a/src/jalview/ws2/gui/WebServicesMenuManager.java b/src/jalview/ws2/gui/WebServicesMenuManager.java index 3757199..f9b8c02 100644 --- a/src/jalview/ws2/gui/WebServicesMenuManager.java +++ b/src/jalview/ws2/gui/WebServicesMenuManager.java @@ -175,6 +175,7 @@ public class WebServicesMenuManager private void addEntriesForAction(ActionI action, JMenu menu, boolean isTopLevel) { + var enabled = isActionEnabled(action); var service = action.getWebService(); String itemName; if (isTopLevel) @@ -196,6 +197,7 @@ public class WebServicesMenuManager if (datastore.hasParameters() || datastore.hasPresets()) text += " with defaults"; JMenuItem item = new JMenuItem(text); + item.setEnabled(enabled); item.addActionListener(e -> { runAction(action, frame.getCurrentView(), Collections.emptyList(), Credentials.empty()); @@ -205,6 +207,7 @@ public class WebServicesMenuManager if (datastore.hasParameters()) { JMenuItem item = new JMenuItem("Edit settings and run..."); + item.setEnabled(enabled); item.addActionListener(e -> { openEditParamsDialog(datastore, null, null).thenAccept(args -> { if (args != null) @@ -218,6 +221,7 @@ public class WebServicesMenuManager { final var presetsMenu = new JMenu(MessageManager.formatMessage( "label.run_with_preset_params", service.getName())); + presetsMenu.setEnabled(enabled); final int dismissDelay = ToolTipManager.sharedInstance() .getDismissDelay(); final int QUICK_TOOLTIP = 1500; @@ -342,6 +346,7 @@ public class WebServicesMenuManager for (ActionI action : actions) { var item = new JMenuItem(action.getFullName()); + item.setEnabled(isActionEnabled(action)); item.addActionListener(e -> setAlternative(action)); atMenu.add(item); } @@ -428,6 +433,12 @@ public class WebServicesMenuManager } } + private boolean isActionEnabled(ActionI action) + { + var isNa = frame.getViewport().getAlignment().isNucleotide(); + return ((isNa && action.doAllowNucleotide()) || + (!isNa && action.doAllowProtein())); + } private void runAction(ActionI action, AlignmentViewport viewport, List args, Credentials credentials)