SciJava Command macro recording

Hi @imagejan @ctrueden @NicoKiaru @haesleinhuepf ,

I have a command with a button:

    @Parameter(label = "Regular expression help", callback = "showRegExpHelp", required = false)
    Button regExpHelpButton;

Now, when I macro record this command and execute the macro code it shows up the button UI, which is not what I want. Could I avoid this?

run("BigDataProcessor2", "directory=/Users/tischer/Documents/fiji-plugin-bigDataProcessor2/src/test/resources/nc1-nt1-calibrated-ij filterpattern=.* namingscheme=[Single Channel Movie] autocontrast=true");


1 Like

@romainGuiet had this issue raised quite some time ago in the forum (too lazy to link it). And the solution was : remove the button…:grimacing:

If this can be solved this would be great


Unpopular opinion: Use generic dialogs


@imagejan Do you know where in the SciJava code base this would have to be changed?

1 Like
  1. Are GenericDialogs always macro recorded or only when they are executed in a certain context, e.g. Plugin class?
  2. Can you have button callbacks in GenericDialogs?
1 Like

here is the previous topic


Hi Tischi,

GenericDialogs get recorded whenever they are executed as long as ImageJ and its Recorder are running. It’s good old Java. No fancy tricks behind.
Furthermore, you can program a plugin with dialog, which calls another plugin (opening another dialog) and both get recorded together. Again, no magic behind.

Yes. I programmed a little example for you. Feel free to play with it and adapt it:




@Christian_Tischer Thanks for asking where this should need to be fixed, appreciate someone trying to tackle the actual issue! :slight_smile: I looked into it for a moment. Hope this fixes it, maybe can be done less hacky, let me know if you have an idea:


Thanks a lot! I will look into it!

1 Like

Thanks @frauzufall for working on it. IMHO the improvements should go in scijava-common, not imagej-legacy. I commented on the PR.


Independent if it’s a Button or anything else, there should be no dialog shown if some parameters are provided and all remaining parameters are required=false.

See the discussion on this issue:


As I said on the issue, I am not entirely convinced. I think we need to have both ways be possible: it should be possible to declare a non-required parameter that wants to be harvested, as well as one that wants not to be in the absence of others. It would be great if someone has sufficient time and energy to think through all the cases including those discussed on the PR and propose a design update to @Parameter that can accommodate all desirable cases.


Hi @ctrueden,

I just found below method in SwingInputWidget:

    protected void setToolTip(JComponent c) {
        String desc = this.get().getItem().getDescription();
        if (desc != null && !desc.isEmpty()) {

Since a large use-case of the buttons seems to be adding documentation, I wonder whether this could be used instead of a button? Do you have an example where a toolTip is used?

And I also had another idea, namely making a new InputWidget for a String that would also contain a help button.

My issue right now is that the help text should be specific to the given input Type, thus the Type should be generic. I paste some code below. If someone has an idea, please let me know, e.g. @NicoKiaru, @maarzt.

@Plugin(type = InputWidget.class, priority = Priority.EXTREMELY_HIGH)
public class SwingStringAndHelpWidget< T extends StringAndHelp > extends SwingInputWidget< T > implements StringAndHelpWidget< T, JPanel > {

    private JTextField textField;
    private JButton helpButton;

    protected void doRefresh() { }

    public boolean supports(final WidgetModel model) {
        return super.supports(model) && model.isType( StringAndHelp.class );

    public T getValue() {
        // TODO: How to create an instance of the object T in order to be able to return something?
        return ??;

    public void set(final WidgetModel model) {

        // TODO: How to get the object T to populate the textField and button
        textField = new JTextField("input");
        helpButton = new JButton( "?" );

        textField.addPropertyChangeListener( (e) -> model.setValue(getValue()));

        getComponent().add( helpButton );
        getComponent().add( textField );
1 Like

We’ve had the same problem in StarDist.

I’ve decided to make a generic SciJava Command CommandFromMacro that (potentially/hopefully) allows to call any Command from IJ1 macro (without the need to press OK even if all required fields are set). The syntax is not ideal, but this is a workaround until the situation has been properly fixed.

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:

Let me know if this is useful for anyone.