Skip to content

Commit e2433d5

Browse files
committed
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 #239 for some discussion.
1 parent a30ddd7 commit e2433d5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/net/imagej/legacy/plugin/MacroPreprocessor.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.scijava.module.process.PreprocessorPlugin;
4141
import org.scijava.plugin.Parameter;
4242
import org.scijava.plugin.Plugin;
43+
import org.scijava.widget.Button;
4344

4445
/**
4546
* Populates the module's input values, when the command is invoked from an
@@ -67,12 +68,16 @@ public void process(final Module module) {
6768
if (!ij1Helper.isMacro()) return;
6869
for (final ModuleItem<?> input : module.getInfo().inputs()) {
6970
final String name = input.getName();
71+
final Class<?> type = input.getType();
7072
final String value = ij1Helper.getMacroParameter(name);
7173
if (value == null) {
7274
// no macro parameter value provided
75+
if (type.equals(Button.class)) {
76+
// skip if input is a button
77+
module.resolveInput(name);
78+
}
7379
continue;
7480
}
75-
final Class<?> type = input.getType();
7681
if (!convertService.supports(value, type)) {
7782
// cannot convert macro value into the input's actual type
7883
continue;

0 commit comments

Comments
 (0)