-
Notifications
You must be signed in to change notification settings - Fork 25
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
MacroRecorder: Improve handling of org.scijava.widget.Button #239
base: master
Are you sure you want to change the base?
Conversation
* button in scijava command will be recorded as buttonName=0 * macro call with buttonName=0 will not display widget with button
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frauzufall @tischi Thanks for digging on this! Before proceeding further, let's spend a moment to consider some scenarios:
- Will someone ever want a command whose dialog box is nothing else than a button? I am inclined you say "Yes, someone might want that." It is after all a simple and UI agnostic way to generate functional button(s) with attached code.
- Will someone ever want a command whose dialog box is a mixture of inputs and buttons—but if all inputs are already resolved, they don't want the box to appear? I'm sure the answer is yes, since that is the scenario here. 😉
- Will someone ever want a command whose dialog box is a mixture of inputs and buttons—and if all inputs are already resolved, still wants the box to appear with only the buttons? I'm not sure, but similar to scenario 1 above, it might come up.
Therefore, I conclude that we need a way to declare the behavior of each button explicitly: a new module item property. We can have a sensible default (either 2 or 3 above), but some people might want the other behavior. The buttonName=0
hack enables people to toggle it running from a macro or script, but it is not fully general, since inputs can be filled from other sources e.g. custom preprocessors. Plus there may be other input types in the future that benefit from this new property. The property would indicate whether the item is intended to be displayed when there are no normal unresolved parameters left, and/or appropriate to be recorded from a macro.
Let's check the ModuleItem
API! The visibility
property looks like a good candidate. There are currently four settings for visibility:
INVISIBLE
- Item is excluded from the history for the purposes of data provenance, and also excluded as a parameter when recording scripts.MESSAGE
- AsINVISIBLE
, and further indicating that the item's value is intended as a message to the user (e.g., in the input harvester panel) rather than an actual parameter to the module execution.NORMAL
- Item is included in the history for purposes of data provenance, and included as a parameter when recording scripts.TRANSIENT
- Item is excluded from the history for the purposes of data provenance, but still included as a parameter when recording scripts.
As an aside, here is the discussion from 2011 where these were discussed and created:
At first I thought it might work to set the Button
to MESSAGE
visibility, because I vaguely remembered that the input harvester might decline to pop a dialog when all unresolved parameters are MESSAGE
visibility. But alas, it still pops up, just as a "question" style dialog rather that "information" one, because the original scenario was to use String
message parameters to ask questions that way.
Regardless: setting a button to "message" is too unintuitive. I think none of the above four visibilities is appropriate, and we need a new one. Reasoning:
Right now, there are two methods isMessageOnly()
and hasWidgets()
of InputPanel
which affect how the InputPanel
/InputHarvester
machinery behaves. If after processing all unresolved inputs, there are no widgets, then the dialog is skipped. Or if the only widgets are message visibility, the dialog becomes a question prompt.
Unfortunately, neither of those outcomes is what we want here. We want a way to say, for each item, whether it should—on its own—trigger a dialog to pop at all. While this is technically a distinct question from "should the item be macro-recorded", for our scenario, we never want button items to be recorded. But what about the general case? This leads to another scenario to consider:
- Will someone ever have a subset of unresolved module items which they don't want shown in a dialog alone, but which they do want to be macro recorded? I don't know...
So: please give it some more thought and come back with a proposal here, and we can then move forward. Here are the questions to ponder and resolve, in my view:
- Is
ItemVisibility
really the best place for this new toggle? Or should it be a new boolean, independent of the visibility? After all, it really has to do with whether to do input harvesting, not whether to record history. (Or does it? How are these two concepts related? Is scenario 4 above a concern? I lean toward not... Thoughts?) - What to name it? I'm blanking on good names for this property. The best I have so far is "stealth" which is terrible. 😜
- What should the default value be for buttons? Stealth, or not stealth?
Finally: some related discussion (as well as links to the SJC3 input harvesting prototype from late 2017) can be found at scijava/scijava-common#42. In that issue, @adaerr suggests:
I wonder whether it is not worth making a special case of purely UI related changes like graying out/disabling or even making invisible items which "aren't really parameters", such as Button widgets (possibly also Visibility=MESSAGE parameters ?
What are the use case of these buttons ?
|
@NicoKiaru In CSBDeep you can change the mapping between the input image and the network input tensor. |
@ctrueden I see. I thought it was a legacy thing since I remember it working in a jython script already, but looking at my scripts I just avoid displaying the button by not calling the preprocessors:
Hope to find the time to work on this in scijava soon. |
Ok, maybe I'm missing some points here, but if we set the flag |
@NicoKiaru Studying the current logic, I don't think setting required to false will have the effect you desire here. Did someone test it? My guess is that it will have no impact on whether the dialog is shown. |
No indeed, it's not working (sorry I should have mentioned it), I was just saying maybe it should / could work like this. Thanks for linking the logic. |
FYI: We’ve also had the problem that the StarDist Command is not executable from IJ1 macro without pressing OK, even if all required parameters are provided. I’ve decided to make a generic SciJava Command You should be able to use this to macro-record/execute your own Command. You can get it by enabling the StarDist update site (it’s not the ideal place to put it, but that’s where it is for now). See this PR for more details: stardist/stardist-imagej#7. |
Hey guys (specially @ctrueden): This does not affect only buttons. It affects also other more 'unusual' widgets such as ColorTable. Here is an example of a prompt in which all parameters have the attribute @ctrueden, I read your notes above. I just wanted to say that (arguably minimal), the IJ1 GenericDialog also supports 1) extraneous buttons (the "Help" button can be renamed and formally hijacked for other functionality); 2) images (which is what a ColorTable is my example above), and 3) HTML messages with functional URLs that can open the browser, etc.. In all these cases, these type of IJ1 widgets were never recorded by the macro recorder. So, if what we are trying to strive here is backwards compatibility, then it would be perfectly fine to not record them. Alternatively, |
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.
I hadn't noticed this whole issue until @tferr's post ten days ago. There's some overlap with other open issues, in particular scijava/scijava-common#402 and scijava/scijava-common#317. I tried to come up with a less intrusive solution (specific to IJ1 macro calls, but not affecting macro recording behavior) in #262. |
Hi @ctrueden, @frauzufall, @imagejan, @tferr, So, let me add one year to the counter and get back to the initial problem 😉 |
@biovoxxel I don't have time to think about this deeply at the moment, but I wanted to respond immediately by reopening this issue so this issue doesn't get lost. I also added it to my community backlog list, which I try to work through all day every Friday, but (I'm sorry to say) that this list is quite long, so I don't know when I'll get back to it. But it's in my queue now! In the meantime, don't let me stop the rest of you from discussing and converging upon a specific technical solution which you can champion, which would accelerate progress here. |
As said above, I would favor my less intrusive suggestion #262, a simple change to @biovoxxel would this work for you? Would you be willing to check out https://github.com/imagej/imagej-legacy/tree/fix-macro-call-button-commands and test? |
Sure, I'm on it to test, will get back to you with results |
Good Morning @imagejan,
I don't see that I made an obvious mistake in that process. I will send you the current version of the BV 3D box jar, so you can test the Voronoi Threshold Labeler with the button in question, since that is still not publicly released. |
My bad. Ignore my last post. The cloned repo did not contain your changes regarding skipping the button an input. I changed it in the |
@imagejan |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: |
Just dropping this here even if it's not completely directly related: I've added in a repo of mine a MessageResolverProcessor, which role is to skip the ui display if all remaining unresolved inputs visibility are |
Yet one more complain about this here: https://forum.image.sc/t/sholl-analysis-from-image-batch-processing/85421 It has been quite a while and I cannot remember the details of why this remains unsolved. What is exactly the hold-up? @NicoKiaru, how does one can reuse your |
Easy quick way: just try to activate the PTBIOP update site, and see if that solves anything. |
Oh I see. It bumps itself so is picked up earlier than the default harvester. Super smart @NicoKiaru! Unfortunately, it does not seem to fix this use case because buttons and LUTs are still being displayed. Unfortunate. These components remain in a prompt. Does anyone know if there is something stalling this that it is not obvious. I'll probably need to look into it, as it affects many SNT commands. |
@tferr does #262 solve this for you? It's less intrusive then this PR (in particular doesn't add a Are there any other UI element input parameters you need to exempt from macro-recording, and resolve in a tolerant way when they're not present in the macro call? |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/sholl-analysis-from-image-batch-processing/85421/5 |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/error-when-using-sholl-analysis-and-snt/85716/1 |
Just me being slow. @tferr feel free to assign me issues and PRs that are especially bothersome to you; doing so gives it a bump in my priority queue. 👍 |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/error-when-using-sholl-analysis-and-snt/85716/3 |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/automize-sholl-analysis-on-tiff-files-of-a-folder/92845/1 |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/trouble-with-sholl-analysis-using-neuroanatomy-in-fiji/101105/5 |
buttonName=0
buttonName=0
will not display widget with buttonShould fix https://forum.image.sc/t/scijava-command-macro-recording/35056
Would be nice to add a test, not sure how this would be done and I don't have more time, happy for pointers! :)