changeset: 236575:f5904b499e57 tag: filechooser-builder-acceptAllFilters tag: qbase tag: qtip tag: tip user: Tomas Mysik date: Fri Oct 19 09:56:15 2012 +0200 summary: [mq]: filechooser-builder-acceptAllFilters diff --git a/openide.filesystems/apichanges.xml b/openide.filesystems/apichanges.xml --- a/openide.filesystems/apichanges.xml +++ b/openide.filesystems/apichanges.xml @@ -49,6 +49,23 @@ Filesystems API + + + New method FileChooserBuilder.setAcceptAllFileFilterUsed. + + + + + +

+ Added + new method to FileChooserBuilder that determines whether the AcceptAll FileFilter + should be used in the created file chooser. +

+
+ + +
New method FileChooserBuilder.addDefaultFileFilters and accompanying annotations. diff --git a/openide.filesystems/manifest.mf b/openide.filesystems/manifest.mf --- a/openide.filesystems/manifest.mf +++ b/openide.filesystems/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.filesystems OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml -OpenIDE-Module-Specification-Version: 8.2 +OpenIDE-Module-Specification-Version: 8.3 diff --git a/openide.filesystems/src/org/openide/filesystems/FileChooserBuilder.java b/openide.filesystems/src/org/openide/filesystems/FileChooserBuilder.java --- a/openide.filesystems/src/org/openide/filesystems/FileChooserBuilder.java +++ b/openide.filesystems/src/org/openide/filesystems/FileChooserBuilder.java @@ -123,6 +123,7 @@ Boolean.getBoolean("forget.recent.dirs"); private SelectionApprover approver; private final List filters = new ArrayList(3); + private boolean useAcceptAllFileFilter = true; /** * Create a new FileChooserBuilder using the name of the passed class * as the metadata for looking up a starting directory from previous @@ -209,6 +210,22 @@ } /** + * Determines whether the 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); } diff --git a/openide.filesystems/test/unit/src/org/openide/filesystems/FileChooserBuilderTest.java b/openide.filesystems/test/unit/src/org/openide/filesystems/FileChooserBuilderTest.java --- a/openide.filesystems/test/unit/src/org/openide/filesystems/FileChooserBuilderTest.java +++ b/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) {