Skip to content

Commit 47c62df

Browse files
committed
Revert "Remove the logic to check that settings a file filter worked in the file chooser."
This reverts commit 0bd1ac0. Remove this logic now prevents the dialog from appearing on my mac...
1 parent a54adfb commit 47c62df

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/main/java/fiji/plugin/trackmate/util/FileChooser.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.File;
2929
import java.io.FilenameFilter;
3030
import java.util.Locale;
31+
import java.util.concurrent.atomic.AtomicBoolean;
3132

3233
import javax.swing.JFileChooser;
3334
import javax.swing.filechooser.FileFilter;
@@ -176,19 +177,33 @@ else if ( parent != null && parent instanceof Dialog )
176177
/*
177178
* Try with a FilenameFilter (may silently fail).
178179
*/
180+
final AtomicBoolean workedWithFilenameFilter = new AtomicBoolean( false );
179181
if ( fileFilter != null )
180182
{
181183
final FilenameFilter filenameFilter = new FilenameFilter()
182184
{
185+
private boolean firstTime = true;
186+
183187
@Override
184188
public boolean accept( final File dir, final String name )
185189
{
190+
if ( firstTime )
191+
{
192+
workedWithFilenameFilter.set( true );
193+
firstTime = false;
194+
}
195+
186196
return fileFilter.accept( new File( dir, name ) );
187197
}
188198
};
189199
fd.setFilenameFilter( filenameFilter );
190200
fd.setVisible( true );
191201
}
202+
if ( fileFilter == null || ( isMac() && !workedWithFilenameFilter.get() ) )
203+
{
204+
fd.setFilenameFilter( null );
205+
fd.setVisible( true );
206+
}
192207

193208
final String filename = fd.getFile();
194209
if ( filename != null )

0 commit comments

Comments
 (0)