private void addEntriesForAction(ActionI<?> action, JMenu menu, boolean isTopLevel)
{
+ var enabled = isActionEnabled(action);
var service = action.getWebService();
String itemName;
if (isTopLevel)
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());
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)
{
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;
for (ActionI<?> action : actions)
{
var item = new JMenuItem(action.getFullName());
+ item.setEnabled(isActionEnabled(action));
item.addActionListener(e -> setAlternative(action));
atMenu.add(item);
}
}
}
+ 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<ArgumentI> args, Credentials credentials)