Skip to content

Commit

Permalink
MacroPreprocessor: resolve Button type inputs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
imagejan committed Apr 10, 2021
1 parent a30ddd7 commit e2433d5
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e2433d5

Please sign in to comment.