Display text label with @ script parameters

imagej
macro
scripting
script-parameters

#1

Hello,
I was wondering if it possible to display a text label using the @script parameters for example to add a link to a wiki page of associated documentation.
I could use a @String but the idea would be to have something immutable. I dont think it is possible currently, possible future improvements ? Eventhough it is not a parameter per see…


#2

Dear @LThomas,

You can use the visibility option for a @Parameter:

#@ String(visibility="MESSAGE", value="Something") somethingString
#@ String(value="Something else") somethingElseString

The first String will be an immutable label, while the second can be changed.

Best,
Stefan


#3

Thanks ! That could be worth adding to the wiki.
Is there some formatting to display hyperlink as well ?


#4

It supports HTML as far as I know. You can try wrapping your text in <html></html> and add a link this way.


#5

Well almost,
# @String(visibility="MESSAGE", value="<html><a href='http://forum.image.sc/'>This is my link</a></html>") Footer
indeed produce a html-formatted string but the link is not clickable :joy:


#6

Sorry, should have thought about that!

@imagejan: Any idea where an issue for this should live? scijava-ui-swing?


#7

Yes, scijava-ui-swing is the correct repository for this.

The class responsible for displaying messages is SwingMessageWidget, which currently simply generates a JLabel with the text:

There’s some extra logic needed to make links work in JLabels, as discussed e.g. in these stackoverflow posts:

I opened an issue to track this:


#8

Thanks for filing that issue, @imagejan!


#9

Hi all, was there any update to this? It would be awesome to link to some documentation URL directly from the script the user is running…


#10

As you can see from the github issue, no…

I started a quick trial implementing JEditorPane as suggested in this old discussion on coderanch:

But it doesn’t work due to a NullPointerException thrown during dialog creation.

Feel free to test it and investigate if you find how to fix this. I’m not planning to invest any more time in it in the next weeks, so unless you or someone else picks it up, the issue might well sit there for another few months.


Regardless, …

I would strongly suggest to rely on the built-in behavior of the search bar that offers a help button for every command for free. Just create a wiki page for your command, and you’re all set.

Not messing with UI dialogs has the added benefit that your module/command/plugin/script will run in a number of headless environments (from within KNIME, from the command line, etc.) withtout any additional work.


#11

I just realized that when recorded using the macro recorder, the tag visibility="MESSAGE" result in having the string actually displayed in a pop-up OK/Cancel window.

Is there a way to prevent that ?
As long as the window is not closed the execution of the macro is interrupted…
Otherwise it works fine to have an uneditable documentation string in the GUI.
The other tags (“NORMAL”, “TRANSIENT”…) are unfortunately all for editable strings…

Does this work with any kind of macro ? How do you do that ?