-
Notifications
You must be signed in to change notification settings - Fork 52
Add possibility to filter by file type in FileWidget #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Adding more attributes to the Maybe we could do something like: @File(label="Open file", style="open:*.xls;*.xlsx") inputFile And extend the mechanism as needed (maybe by additional plugins...) to support whatever syntax is useful for specifying file filters. This could include useful stuff like "image formats only" (in all formats ImageJ supports), "text formats only", etc. The downside of tying this metadata to the Validation in general could certainly use some improvement in the framework; see #47 for details. |
In particular, it would be useful if you can provide a Do we have to change For example: Also, we should consider whether this filter restricts the allowed files, or we use it simply to facilitate file choice by offering multiple filter types in the "File of Type" dropdown for |
With scijava/scijava-ui-swing@73281ec (see also scijava/scijava-ui-swing#27), filtering by file extension is now possible with the following syntax:
So this is implemented at the UI level. If at some point we want to restrict file types at the |
I am not exactly sure what you mean by implemented at the UI level, but following this forum post I reopen the issue. It seems that trying to use |
Seeing my comment above, this must have worked at the time of writing. If it doesn't now, it's a regression. I'll reopen the issue. |
I dug in the code a bit, I could find only one place in the However there is no case above this line for a |
The filter is derived from the As I wrote above, it was working at the time when we implemented and tested it. It might be that some changes in the framework broke the functionality in some situations, though. We'll have to test all of these:
|
While testing for extensions, I also noticed that
As a single parameter does not seem to have the expected behaviour, it still allows the selection of files. The single-file widget works as expected. EDIT : My fault, it works, just using |
Thanks @LauLauThom for testing. Note that the
Do we really want to allow this? It feels to me like being tolerant of typos and also allowing |
It would be great if you could ask for a specified file type in a parameter definition:
so that the resulting FileWidget dialog would filter the directory by file type.
The text was updated successfully, but these errors were encountered: