+ Added
+ new method to FileChooserBuilder
that determines whether the AcceptAll FileFilter
+ should be used in the created file chooser.
+
AcceptAll FileFilter
is used
+ * as an available choice in the choosable filter list.
+ * If false, the AcceptAll
file filter is removed from
+ * the list of available file filters.
+ * If true, the AcceptAll
file filter will become the
+ * the actively used file filter.
+ * @param accept whether the AcceptAll FileFilter
is used
+ * @return this
+ * @since 8.3
+ */
+ public FileChooserBuilder setAcceptAllFileFilterUsed(boolean accept) {
+ useAcceptAllFileFilter = accept;
+ return this;
+ }
+
+ /**
* Set the current directory which should be used only if
* a last-used directory cannot be found for the key string passed
* into this builder's constructor.
@@ -387,6 +404,7 @@
JFileChooser.FILES_AND_DIRECTORIES);
chooser.setFileHidingEnabled(fileHiding);
chooser.setControlButtonsAreShown(controlButtonsShown);
+ chooser.setAcceptAllFileFilterUsed(useAcceptAllFileFilter);
if (title != null) {
chooser.setDialogTitle(title);
}
--- a/openide.filesystems/test/unit/src/org/openide/filesystems/FileChooserBuilderTest.java
+++ a/openide.filesystems/test/unit/src/org/openide/filesystems/FileChooserBuilderTest.java
@@ -223,6 +223,13 @@
assertEquals (ff.size() + 1, actual.size());
}
+ public void testSetAcceptAllFileFilterUsed() {
+ FileChooserBuilder instance = new FileChooserBuilder("k");
+ assertTrue(instance.createFileChooser().isAcceptAllFileFilterUsed());
+ instance.setAcceptAllFileFilterUsed(false);
+ assertFalse(instance.createFileChooser().isAcceptAllFileFilterUsed());
+ }
+
private static final class FF extends FileFilter {
private String x;
FF(String x) {