Login  Register

Re: File selection in GenericDialog

Posted by Jan Eglinger on Aug 18, 2017; 12:04pm
URL: http://imagej.273.s1.nabble.com/File-selection-in-GenericDialog-tp5019222p5019233.html

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