Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix NullPointerException when chooseFiles returns null
  • Loading branch information
ctrueden authored and imagejan committed Jul 21, 2017
commit de98dcf722c347419b3322b06ae329be755862c5
13 changes: 7 additions & 6 deletions src/main/java/org/scijava/ui/UserInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ default File chooseFile(String title, File file, String style) {
*
* @param files The initial value displayed in the file chooser prompt.
* @param filter A filter allowing to restrict file choice.
* @return The selected {@link File}s chosen by the user, or null if prompt is not
* available
* @return The selected {@link File}s chosen by the user, or null if the
* user cancels the prompt.
*/
default File[] chooseFiles(File[] files, FileFilter filter) {
throw new UnsupportedOperationException();
Expand All @@ -205,12 +205,13 @@ default File[] chooseFiles(File[] files, FileFilter filter) {
*
* @param fileList The initial value displayed in the file chooser prompt.
* @param filter A filter allowing to restrict file choice.
* @return The selected {@link File}s chosen by the user, or null if prompt is not
* available
* @return The selected {@link File}s chosen by the user, or null if the
* user cancels the prompt.
*/
default List<File> chooseFiles(List<File> fileList, FileFilter filter) {
File[] files = fileList.toArray(new File[fileList.size()]);
return Arrays.asList(chooseFiles(files, filter));
final File[] initialFiles = fileList.toArray(new File[fileList.size()]);
final File[] chosenFiles = chooseFiles(initialFiles, filter);
return chosenFiles == null ? null : Arrays.asList(chosenFiles);
}

/**
Expand Down