Skip to content

Commit

Permalink
Make file filter show the extension, instead of cryptic stuff
Browse files Browse the repository at this point in the history
* Override FileFilter toString() method in SwingFileWidget so that it shows the extension(s) that are filtered by the file choose dialog instead of the standard toString() of the
* Related to
  * bigdataviewer/bigdataviewer-playground#110
  * https://forum.image.sc/t/scijava-command-file-extensions/29869/2
  • Loading branch information
stefanhahmann committed May 28, 2024
1 parent 2770bbf commit 7e9109d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/org/scijava/ui/swing/widget/SwingFileWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
import java.util.stream.Collectors;

import javax.swing.Box;
Expand Down Expand Up @@ -235,6 +236,18 @@ public boolean accept(final File pathname) {
}
return false;
}

@Override
public String toString()
{
List< String > extsWithPrefix = new ArrayList<>();
for ( String ext : exts )
extsWithPrefix.add( "*." + ext );

StringJoiner joiner = new StringJoiner( ";" );
extsWithPrefix.forEach( joiner::add );
return joiner.toString();
}
};
}

Expand Down

0 comments on commit 7e9109d

Please sign in to comment.