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
Allow including and excluding files from the list using globbing pattern - p3 #19
Comments
I need to think about this a bit. For uniformity, I'd like to keep the implementation itself based around filters, but we could use a more terse API to create them (similar to the above example) and to allow for one or more filters to be invisibly and always enabled. |
I'd like to nail down the semantics of globbing filters. An isolated "include" glob is easy to understand, as is an isolated "exclude" glob. Combining arbitrary includes and excludes is somewhat less easy to understand, and there are many different ways to interpret the combinations. I generally favour the semantics provided by sequential evaluation with explicit halts. The key thing to note is that the rules are evaluated in declaration order, and the difference here would be that the match patterns would be the glob syntax supported by |
I see what you mean. builder.addIncludeFileFilter( "**.{md,Rmd,markdown}", "Markdown Files" );
builder.addExcludeFileFilter( "*.*md" ); I'd expect that all // Don't permit exclude before include?
builder.addExcludeFileFilter( "*.*md" );
builder.addIncludeFileFilter( "**.{md,Rmd,markdown}", "Markdown Files" ); // throw?
// Don't permit include after exclude?
builder.addIncludeFileFilter( "**.{md,Rmd,markdown}", "Markdown Files" );
builder.addExcludeFileFilter( "*.*md" );
builder.addIncludeFileFilter( "**.{asc,text}", "Text Files" ); // throw? Even evaluating in declaration order without exceptions is fine, if you think it'll work. My preference is to force the programmer to deal with potentially ambiguous outcomes. |
You might want to take a look at the |
I've merged the |
Release: com.io7m.jwheatsheaf 3.0.0 A big thanks to @DaveJarvis for suggestions, bug reports, and some code contributions! Change: Add the ability to specify custom strings (Ticket: #7) Change: Add the ability to confirm file selections (Ticket: #17) Change: Allow for including ".." in directory listings (Ticket: #23) Change: Improve "select directly" dialog behaviour (Ticket: #29) Change: Fix the size formatter (Ticket: #30) Change: Use the default filesystem by default (Ticket: #21) Change: Add support for glob-based filters (Ticket: #19) Change: Improve filename field behaviour (Ticket: #28) Change: Add an optional home directory button (Ticket: #12) Change: Enable sorting of directory items (Ticket: #22) Change: Allow for setting a default file filter (Ticket: #9) Change: Allow the escape key to close file choosers (Ticket: #14) Change: Allow for specifying an initial filename in choosers (Ticket: #15) Change: Allow for specifying custom dialog titles (Ticket: #8) Change: Make the default filters part of the public API (Ticket: #10)
Release: com.io7m.jwheatsheaf 3.0.0 A big thanks to @DaveJarvis for suggestions, bug reports, and some code contributions! Change: Add the ability to specify custom strings (Ticket: #7) Change: Add the ability to confirm file selections (Ticket: #17) Change: Allow for including ".." in directory listings (Ticket: #23) Change: Improve "select directly" dialog behaviour (Ticket: #29) Change: Fix the size formatter (Ticket: #30) Change: Use the default filesystem by default (Ticket: #21) Change: Add support for glob-based filters (Ticket: #19) Change: Improve filename field behaviour (Ticket: #28) Change: Add an optional home directory button (Ticket: #12) Change: Enable sorting of directory items (Ticket: #22) Change: Allow for setting a default file filter (Ticket: #9) Change: Allow the escape key to close file choosers (Ticket: #14) Change: Allow for specifying an initial filename in choosers (Ticket: #15) Change: Allow for specifying custom dialog titles (Ticket: #8) Change: Make the default filters part of the public API (Ticket: #10)
Sometimes users (or developers) may wish to hide certain files. It would be convenient to use a globbing pattern in such cases. For example, consider the following API:
Multiple calls would be permitted, as well as mixing. Such as:
This API is a bit simpler, IMO, than creating
JWFileChooserFilterType
instances. (It's syntactic sugar, really.)Given that the user cannot select excluded files, it needs no description. See FileSystem.getPathMatcher for globbing details.
The text was updated successfully, but these errors were encountered: