From e2433d58ee5fdc9ff54d995e00d098c7b25e93b4 Mon Sep 17 00:00:00 2001 From: Jan Eglinger Date: Sat, 10 Apr 2021 21:57:15 +0200 Subject: [PATCH] MacroPreprocessor: resolve Button type inputs When calling a command from a macro, we usually don't want to show a UI dialog. If the called command contains inputs of type Button, we resolve these without setting them, as we assume that buttons and their callbacks provide some interactivity that is not required when running from macro. See https://github.com/imagej/imagej-legacy/pull/239 for some discussion. --- .../java/net/imagej/legacy/plugin/MacroPreprocessor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/imagej/legacy/plugin/MacroPreprocessor.java b/src/main/java/net/imagej/legacy/plugin/MacroPreprocessor.java index 3348b5c58..0c9395298 100644 --- a/src/main/java/net/imagej/legacy/plugin/MacroPreprocessor.java +++ b/src/main/java/net/imagej/legacy/plugin/MacroPreprocessor.java @@ -40,6 +40,7 @@ import org.scijava.module.process.PreprocessorPlugin; import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import org.scijava.widget.Button; /** * Populates the module's input values, when the command is invoked from an @@ -67,12 +68,16 @@ public void process(final Module module) { if (!ij1Helper.isMacro()) return; for (final ModuleItem input : module.getInfo().inputs()) { final String name = input.getName(); + final Class type = input.getType(); final String value = ij1Helper.getMacroParameter(name); if (value == null) { // no macro parameter value provided + if (type.equals(Button.class)) { + // skip if input is a button + module.resolveInput(name); + } continue; } - final Class type = input.getType(); if (!convertService.supports(value, type)) { // cannot convert macro value into the input's actual type continue;