ImageJ2 Plugin Parameter Styles

imagej
plugin
imagej2

#1

Hi All,

I am trying to find a list of all available options for:

@Parameter (style = "???")

I found this page, but there only was one example: https://imagej.net/Script_Parameters#Styles

www

@imagejan
Is there more information somewhere else on the web?

java

Ideal would be also something that one can “see” from within an java IDE, maybe something like

class WidgetStyles
{
public final static String[ ] styles = new String[ ]{"directory", "..." };
}

with all current options, or something similar?! Maybe this exists?

But I could not find it, e.g. here: http://javadoc.scijava.org/SciJava/index.html?org/scijava/plugin/Parameter.html

password

@ctrueden
And I also would like to ask one more specific question. I am writing an IJ2 plugin for submitting IJ2 commands to a Slurm cluster. For this, the user needs to enter a password for logging into the cluster. Is there a “password style”, which hides the typed text? Or is some other way recommended to get the users credentials?

Best, Christian


#2

very intersting post, thanks for these questions @Christian_Tischer


#3

Each parameter type (e.g. String, Integer, File, etc.) generates its own widget, and the availability of style attributes is defined by each widget implementation. So far (and as things are still being developed), this information is only present in the javadoc of each of the subinterfaces extending InputWidget (see the All Known Subinterfaces section of the InputWidget javadoc).

See here for a list of widget classes in the source repository: https://github.com/scijava/scijava-common/tree/master/src/main/java/org/scijava/widget

I agree that it’d be useful to have this information somewhere on a centralized page (https://imagej.net/Script_Parameters), I’ll try to add some info there. We should however include links to the sources wherever possible, to minimize the effort of maintaining yet another documentation page, and to avoid that the documentation falls out of date when things update in scijava-common.

Yes, it’s defined in the TextWidget interface:

so in Java, you’d use it as:

@Parameter (style = TextWidget.PASSWORD_STYLE)
private String pwd;

#4

@ctrueden, Thank you very much for this very helpful answer!!


#5

Do you mean “@imagejan Thank you”? :wink: If so, seconded! :smile:


#6

Yes! Sorry!
@imagejan: Thank you!
:slight_smile:


#7

@ctrueden @imagejan
I started reading a bit about security and it seems like that returning a char[ ] rather than a String is believed to be more secure (see below).

I am bringing this up, because - as mentioned above - I am developing a “RunImageJ2CommandOnSlurmCluster” plugin, which I believe is very useful to have.

However, to use this service the users need to enter their full credentials into the plugin, because I am using JSch for establishing an SSH connection to the cluster.

Thus, I am worried in terms of doing things as safe as possible.

What are your opinons/recommendations about this?


getPassword from UI
#8

I agree that it would be nice to be able to annotate @Parameter char[] str and have that use a text widget. But I expect it does not work, currently. It will work in the next generation of the widget framework design, which no longer uses generics to constrain the types. A String or any CharSequence or char[] parameter should all be able to use the same text widget, without any convoluted shenanigans.