File selection in GenericDialog

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

File selection in GenericDialog

Nico Stuurman
I am in the process of writing a plugin that takes about 6 file paths in
its input.  I would like to use a GenericDialog for user input (to
ensure that the plugin will be macro-recordable), but can not seem to
find an easy way to add the standard button with three dots (i.e. "...")
that the user can click to open a File (or Directory) Open Dialog to
populate the text field with that information.  Is there a way of doing
this with the existing GenericDialog, or should I extend GenericDialog
to add such functionality?

Thanks for your help!

Best,

Nico

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: File selection in GenericDialog

Jan Eglinger
Hi Nico,

this feature was added in Fiji's GenericDialogPlus, see the
addFileField() and addDirectoryField() methods:

http://javadoc.imagej.net/Fiji/fiji/util/gui/GenericDialogPlus.html


However, you shouldn't need to use GenericDialog or its derivatives at
all any more if you switch to using SciJava parameters:


@Plugin(type = Command.class, menuPath = "Plugins > My Plugin")
public class MyPlugin implements Command {

     @Parameter (label = "Please select input file")
     private File input1;

     @Parameter (style = FileWidget.DIRECTORY_STYLE, label = "Input folder")
     private File input2;

     @Parameter (style = FileWidget.SAVE_STYLE, label = "Save to file")
     private File input3;

     ...

}


See also:
https://github.com/imagej/example-imagej-command

Cheers
Jan


On 17.08.2017 22:31, Nico Stuurman wrote:

> I am in the process of writing a plugin that takes about 6 file paths in
> its input.  I would like to use a GenericDialog for user input (to
> ensure that the plugin will be macro-recordable), but can not seem to
> find an easy way to add the standard button with three dots (i.e. "...")
> that the user can click to open a File (or Directory) Open Dialog to
> populate the text field with that information.  Is there a way of doing
> this with the existing GenericDialog, or should I extend GenericDialog
> to add such functionality?
>
> Thanks for your help!
>
> Best,
>
> Nico
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: File selection in GenericDialog

Nico Stuurman
Hi Jan and others,


Thanks!

> this feature was added in Fiji's GenericDialogPlus, see the
> addFileField() and addDirectoryField() methods:
>
> http://javadoc.imagej.net/Fiji/fiji/util/gui/GenericDialogPlus.html
>
>
> However, you shouldn't need to use GenericDialog or its derivatives at
> all any more if you switch to using SciJava parameters:

Is it correct that none of these two solutions will work with the plain
ImageJ1 distribution?

I guess that I could simply include my own copy of the
fiji.util.gui.GenericDialogPlus to make the plugin compatible with ImageJ1?


Thanks!


Nico

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: File selection in GenericDialog

ctrueden
Hi Nico,

> I guess that I could simply include my own copy of the
> fiji.util.gui.GenericDialogPlus to make the plugin compatible with
> ImageJ1?

If you want to distribute your plugin to others, please do not fork classes
like that. Or if you do, at least rename it first. Otherwise, your plugin
and the Fiji distribution itself will have clashing code in
fiji.util.gui.GenericDialogPlus, and then anyone trying to use your plugin
in Fiji will have problems.

It is better to build on the existing libraries, and contribute any needed
changes upstream, rather than mutate them.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Fri, Aug 18, 2017 at 2:06 PM, Nico Stuurman <[hidden email]>
wrote:

> Hi Jan and others,
>
>
> Thanks!
>
> this feature was added in Fiji's GenericDialogPlus, see the addFileField()
>> and addDirectoryField() methods:
>>
>> http://javadoc.imagej.net/Fiji/fiji/util/gui/GenericDialogPlus.html
>>
>>
>> However, you shouldn't need to use GenericDialog or its derivatives at
>> all any more if you switch to using SciJava parameters:
>>
>
> Is it correct that none of these two solutions will work with the plain
> ImageJ1 distribution?
>
> I guess that I could simply include my own copy of the
> fiji.util.gui.GenericDialogPlus to make the plugin compatible with
> ImageJ1?
>
>
> Thanks!
>
>
>
> Nico
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html