Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacroPreprocessor: resolve Button type inputs #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

imagejan
Copy link
Member

When calling a command from a macro (with an option string), we usually don't want to show a UI dialog.

If the called command contains inputs of type org.scijava.widget.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 the closed PR #239 for some discussion.


I would have liked to respect a required={false,true} annotation for the Button input, but since Button extends Optional, isRequired() will always resolve to false, see also:

https://github.com/scijava/scijava-common/blob/46ca0d04c5c86eeb51f9daa9f130b0d7c8decd65/src/main/java/org/scijava/command/CommandModuleItem.java#L102-L106


I hope that this solution - while being a bit hacky - is less intrusive than #239, but still meets the requirements of the affected projects.

(/cc @frauzufall @NicoKiaru @tischi @romainGuiet @uschmidt83 @tferr)

Note 1: While in full-fledged scripting languages, you can always call commandService.run("command",false, ...) to avoid the automatic command preprocessing (and hence display of dialogs), this option doesn't exist in an IJ1 macro run("...") call.

Note 2: This pull request still allows commands whose dialog box is nothing else than a button to show a dialog box when invoked from the UI (scenario 1 in this comment by @ctrueden).

Note 3: I tried to add a test for this behavior in 401cb9c, but it's not headless, as it seems this issue only occurs when running from a macro with the UI displayed. In addition, we still cannot distinguish between macro calls with and without option string (run("Test Command") vs. run("Test Command", ""), see also scijava/scijava-common#317 (comment)).

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.
@imagejan
Copy link
Member Author

See #239 (comment), thanks @biovoxxel for testing!

@hinerm @ctrueden is there any chance we can get this merged and released soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant